Search in sources :

Example 1 with TokenIdentityConfig

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();
}
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 TokenIdentityConfig

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

Example 3 with TokenIdentityConfig

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

Example 4 with TokenIdentityConfig

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

Example 5 with TokenIdentityConfig

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

Aggregations

TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)9 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 RealmConfig (com.hazelcast.config.security.RealmConfig)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)2 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)2 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)2 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)2 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)2 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)2 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)2 TokenEncoding (com.hazelcast.config.security.TokenEncoding)2 UsernamePasswordIdentityConfig (com.hazelcast.config.security.UsernamePasswordIdentityConfig)2 CredentialsFactoryConfig (com.hazelcast.config.CredentialsFactoryConfig)1 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)1 YamlConfigBuilderTest (com.hazelcast.config.YamlConfigBuilderTest)1 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)1 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)1 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)1