use of com.hazelcast.config.security.UsernamePasswordIdentityConfig 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.UsernamePasswordIdentityConfig in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method usernamePasswordIdentity.
@Test
public void usernamePasswordIdentity() {
UsernamePasswordIdentityConfig identityConfig = new UsernamePasswordIdentityConfig("tester", "s3cr3T");
clientConfig.getSecurityConfig().setUsernamePasswordIdentityConfig(identityConfig);
ClientConfig actual = newConfigViaGenerator();
assertEquals(identityConfig, actual.getSecurityConfig().getUsernamePasswordIdentityConfig());
}
use of com.hazelcast.config.security.UsernamePasswordIdentityConfig in project hazelcast by hazelcast.
the class ConfigXmlGenerator method securityRealmGenerator.
protected void securityRealmGenerator(XmlGenerator gen, String name, RealmConfig c) {
gen.open("realm", "name", name);
if (c.isAuthenticationConfigured()) {
gen.open("authentication");
jaasAuthenticationGenerator(gen, c.getJaasAuthenticationConfig());
tlsAuthenticationGenerator(gen, c.getTlsAuthenticationConfig());
ldapAuthenticationGenerator(gen, c.getLdapAuthenticationConfig());
kerberosAuthenticationGenerator(gen, c.getKerberosAuthenticationConfig());
simpleAuthenticationGenerator(gen, c.getSimpleAuthenticationConfig());
gen.close();
}
if (c.isIdentityConfigured()) {
gen.open("identity");
CredentialsFactoryConfig cf = c.getCredentialsFactoryConfig();
if (cf != null) {
gen.open("credentials-factory", "class-name", cf.getClassName()).appendProperties(cf.getProperties()).close();
}
UsernamePasswordIdentityConfig upi = c.getUsernamePasswordIdentityConfig();
if (upi != null) {
gen.node("username-password", null, "username", upi.getUsername(), "password", getOrMaskValue(upi.getPassword()));
}
TokenIdentityConfig ti = c.getTokenIdentityConfig();
if (ti != null) {
gen.node("token", getOrMaskValue(ti.getTokenEncoded()), "encoding", ti.getEncoding().toString());
}
kerberosIdentityGenerator(gen, c.getKerberosIdentityConfig());
gen.close();
}
gen.close();
}
Aggregations