use of com.hazelcast.config.security.TokenIdentityConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGenerator method security.
private static void security(XmlGenerator gen, ClientSecurityConfig security) {
if (security == null) {
return;
}
gen.open("security");
UsernamePasswordIdentityConfig upConfig = security.getUsernamePasswordIdentityConfig();
if (upConfig != null) {
gen.node("username-password", null, "username", upConfig.getUsername(), "password", upConfig.getPassword());
}
TokenIdentityConfig tic = security.getTokenIdentityConfig();
if (tic != null) {
gen.node("token", tic.getTokenEncoded(), "encoding", tic.getEncoding());
}
CredentialsFactoryConfig cfConfig = security.getCredentialsFactoryConfig();
if (cfConfig != null) {
gen.open("credentials-factory", "class-name", cfConfig.getClassName()).appendProperties(cfConfig.getProperties()).close();
}
kerberosIdentityGenerator(gen, security.getKerberosIdentityConfig());
Map<String, RealmConfig> realms = security.getRealmConfigs();
if (realms != null && !realms.isEmpty()) {
gen.open("realms");
for (Map.Entry<String, RealmConfig> realmEntry : realms.entrySet()) {
securityRealmGenerator(gen, realmEntry.getKey(), realmEntry.getValue());
}
gen.close();
}
gen.close();
}
use of com.hazelcast.config.security.TokenIdentityConfig in project hazelcast by hazelcast.
the class YamlMemberDomConfigProcessor method handleToken.
@Override
protected void handleToken(RealmConfig realmConfig, Node node) {
TokenEncoding encoding = TokenEncoding.getTokenEncoding(getAttribute(node, "encoding"));
TokenIdentityConfig tic = new TokenIdentityConfig(encoding, getAttribute(node, "value"));
realmConfig.setTokenIdentityConfig(tic);
}
use of com.hazelcast.config.security.TokenIdentityConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method tokenIdentity.
@Test
public void tokenIdentity() {
TokenIdentityConfig identityConfig = new TokenIdentityConfig(TokenEncoding.BASE64, "bmF6ZGFy");
clientConfig.getSecurityConfig().setTokenIdentityConfig(identityConfig);
ClientConfig actual = newConfigViaGenerator();
assertEquals(identityConfig, actual.getSecurityConfig().getTokenIdentityConfig());
}
use of com.hazelcast.config.security.TokenIdentityConfig in project hazelcast by hazelcast.
the class YamlClientConfigBuilderTest method testTokenIdentityConfig.
@Override
@Test
public void testTokenIdentityConfig() {
String yaml = "" + "hazelcast-client:\n" + " security:\n" + " token:\n" + " encoding: base64\n" + " value: SGF6ZWxjYXN0\n";
ClientConfig config = buildConfig(yaml);
TokenIdentityConfig tokenIdentityConfig = config.getSecurityConfig().getTokenIdentityConfig();
assertNotNull(tokenIdentityConfig);
assertArrayEquals("Hazelcast".getBytes(StandardCharsets.US_ASCII), tokenIdentityConfig.getToken());
assertEquals("SGF6ZWxjYXN0", tokenIdentityConfig.getTokenEncoded());
}
use of com.hazelcast.config.security.TokenIdentityConfig in project hazelcast by hazelcast.
the class XmlClientConfigBuilderTest method testTokenIdentityConfig.
@Override
@Test
public void testTokenIdentityConfig() {
String xml = HAZELCAST_CLIENT_START_TAG + "<security>" + " <token encoding='base64'>SGF6ZWxjYXN0</token>" + "</security>" + HAZELCAST_CLIENT_END_TAG;
ClientConfig config = buildConfig(xml);
TokenIdentityConfig tokenIdentityConfig = config.getSecurityConfig().getTokenIdentityConfig();
assertNotNull(tokenIdentityConfig);
assertArrayEquals("Hazelcast".getBytes(StandardCharsets.US_ASCII), tokenIdentityConfig.getToken());
assertEquals("SGF6ZWxjYXN0", tokenIdentityConfig.getTokenEncoded());
}
Aggregations