Search in sources :

Example 1 with UsernamePasswordIdentityConfig

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();
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) UsernamePasswordIdentityConfig(com.hazelcast.config.security.UsernamePasswordIdentityConfig) CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) Map(java.util.Map)

Example 2 with UsernamePasswordIdentityConfig

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());
}
Also used : UsernamePasswordIdentityConfig(com.hazelcast.config.security.UsernamePasswordIdentityConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with UsernamePasswordIdentityConfig

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();
}
Also used : UsernamePasswordIdentityConfig(com.hazelcast.config.security.UsernamePasswordIdentityConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig)

Aggregations

UsernamePasswordIdentityConfig (com.hazelcast.config.security.UsernamePasswordIdentityConfig)3 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)2 CredentialsFactoryConfig (com.hazelcast.config.CredentialsFactoryConfig)1 RealmConfig (com.hazelcast.config.security.RealmConfig)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Map (java.util.Map)1 Test (org.junit.Test)1