Search in sources :

Example 1 with RealmConfig

use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.

the class TcpIpHostnameJoinTest method test_whenSameClusterNamesButDifferentPasswordMixedHostnames.

@Test
public void test_whenSameClusterNamesButDifferentPasswordMixedHostnames() {
    Config config1 = new Config();
    config1.setProperty(ClusterProperty.WAIT_SECONDS_BEFORE_JOIN.getName(), "0");
    config1.setProperty(ClusterProperty.MAX_JOIN_SECONDS.getName(), "3");
    config1.getSecurityConfig().setMemberRealmConfig("m1", new RealmConfig().setUsernamePasswordIdentityConfig("foo", "Here"));
    config1.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).setConnectionTimeoutSeconds(3).addMember(HOSTNAME1);
    Config config2 = new Config();
    config2.setProperty(ClusterProperty.WAIT_SECONDS_BEFORE_JOIN.getName(), "0");
    config2.setProperty(ClusterProperty.MAX_JOIN_SECONDS.getName(), "3");
    config2.getSecurityConfig().setMemberRealmConfig("m1", new RealmConfig().setUsernamePasswordIdentityConfig("foo", "There"));
    config2.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).setConnectionTimeoutSeconds(3).addMember(HOSTNAME2);
    HazelcastInstance hz1 = Hazelcast.newHazelcastInstance(config1);
    HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(config2);
    assertClusterSize(2, hz1);
    assertClusterSize(2, hz2);
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) JoinConfig(com.hazelcast.config.JoinConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with RealmConfig

use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.

the class ConfigCheckTest method whenGroupPasswordDifferent_thenJoin.

@Test
public void whenGroupPasswordDifferent_thenJoin() {
    Config config1 = new Config();
    config1.setClusterName("c1");
    config1.getSecurityConfig().setMemberRealmConfig("m1", new RealmConfig().setUsernamePasswordIdentityConfig("foo", "Here"));
    Config config2 = new Config();
    config2.setClusterName("c1");
    config2.getSecurityConfig().setMemberRealmConfig("m2", new RealmConfig().setUsernamePasswordIdentityConfig("foo", "There"));
    ConfigCheck configCheck1 = new ConfigCheck(config1, "joiner");
    ConfigCheck configCheck2 = new ConfigCheck(config2, "joiner");
    assertIsCompatibleTrue(configCheck1, configCheck2);
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) ConfigCheck(com.hazelcast.internal.cluster.impl.ConfigCheck) Config(com.hazelcast.config.Config) RealmConfig(com.hazelcast.config.security.RealmConfig) PartitionGroupConfig(com.hazelcast.config.PartitionGroupConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with RealmConfig

use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.

the class ConfigXmlGeneratorTest method testIfSensitiveDataIsNotMasked_whenMaskingDisabled.

@Test
public void testIfSensitiveDataIsNotMasked_whenMaskingDisabled() {
    String password = "Hazelcast";
    String salt = "theSalt";
    String licenseKey = "HazelcastLicenseKey";
    Config cfg = new Config();
    cfg.getSecurityConfig().setMemberRealmConfig("mr", new RealmConfig().setUsernamePasswordIdentityConfig("user", password));
    SSLConfig sslConfig = new SSLConfig();
    sslConfig.setProperty("keyStorePassword", password).setProperty("trustStorePassword", password);
    cfg.getNetworkConfig().setSSLConfig(sslConfig);
    SymmetricEncryptionConfig symmetricEncryptionConfig = new SymmetricEncryptionConfig();
    symmetricEncryptionConfig.setPassword(password);
    symmetricEncryptionConfig.setSalt(salt);
    cfg.getNetworkConfig().setSymmetricEncryptionConfig(symmetricEncryptionConfig);
    cfg.setLicenseKey(licenseKey);
    Config newConfigViaXMLGenerator = getNewConfigViaXMLGenerator(cfg, false);
    SSLConfig generatedSSLConfig = newConfigViaXMLGenerator.getNetworkConfig().getSSLConfig();
    assertEquals(generatedSSLConfig.getProperty("keyStorePassword"), password);
    assertEquals(generatedSSLConfig.getProperty("trustStorePassword"), password);
    String secPassword = newConfigViaXMLGenerator.getNetworkConfig().getSymmetricEncryptionConfig().getPassword();
    String theSalt = newConfigViaXMLGenerator.getNetworkConfig().getSymmetricEncryptionConfig().getSalt();
    assertEquals(secPassword, password);
    assertEquals(theSalt, salt);
    assertEquals(newConfigViaXMLGenerator.getLicenseKey(), licenseKey);
    SecurityConfig securityConfig = newConfigViaXMLGenerator.getSecurityConfig();
    RealmConfig realmConfig = securityConfig.getRealmConfig(securityConfig.getMemberRealm());
    assertEquals(realmConfig.getUsernamePasswordIdentityConfig().getPassword(), password);
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) TlsAuthenticationConfig(com.hazelcast.config.security.TlsAuthenticationConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) JetConfig(com.hazelcast.jet.config.JetConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with RealmConfig

use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.

the class ConfigXmlGeneratorTest method testSimpleAuthenticationConfig.

@Test
public void testSimpleAuthenticationConfig() {
    Config cfg = new Config();
    RealmConfig realmConfig = new RealmConfig().setSimpleAuthenticationConfig(new SimpleAuthenticationConfig().setRoleSeparator(":").addUser("test", "1234", "monitor", "hazelcast").addUser("dev", "secret", "root"));
    SecurityConfig expectedConfig = new SecurityConfig().setMemberRealmConfig("simpleRealm", realmConfig);
    cfg.setSecurityConfig(expectedConfig);
    SecurityConfig actualConfig = getNewConfigViaXMLGenerator(cfg).getSecurityConfig();
    assertEquals(expectedConfig, actualConfig);
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) TlsAuthenticationConfig(com.hazelcast.config.security.TlsAuthenticationConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) JetConfig(com.hazelcast.jet.config.JetConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with RealmConfig

use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.

the class ConfigXmlGeneratorTest method testLdapConfig.

@Test
public void testLdapConfig() {
    Config cfg = new Config();
    RealmConfig realmConfig = new RealmConfig().setLdapAuthenticationConfig(new LdapAuthenticationConfig().setSkipIdentity(TRUE).setSkipEndpoint(FALSE).setSkipRole(TRUE).setParseDn(true).setPasswordAttribute("passwordAttribute").setRoleContext("roleContext").setRoleFilter("roleFilter").setRoleMappingAttribute("roleMappingAttribute").setRoleMappingMode(LdapRoleMappingMode.REVERSE).setRoleNameAttribute("roleNameAttribute").setRoleRecursionMaxDepth(25).setRoleSearchScope(LdapSearchScope.OBJECT).setSocketFactoryClassName("socketFactoryClassName").setSystemUserDn("systemUserDn").setSystemUserPassword("systemUserPassword").setSystemAuthentication("GSSAPI").setSecurityRealm("krb5Initiator").setUrl("url").setUserContext("userContext").setUserFilter("userFilter").setUserNameAttribute("userNameAttribute").setUserSearchScope(LdapSearchScope.ONE_LEVEL).setSkipAuthentication(TRUE));
    SecurityConfig expectedConfig = new SecurityConfig().setClientRealmConfig("ldapRealm", realmConfig);
    cfg.setSecurityConfig(expectedConfig);
    SecurityConfig actualConfig = getNewConfigViaXMLGenerator(cfg).getSecurityConfig();
    assertEquals(expectedConfig, actualConfig);
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) TlsAuthenticationConfig(com.hazelcast.config.security.TlsAuthenticationConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) SemaphoreConfig(com.hazelcast.config.cp.SemaphoreConfig) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) SimpleAuthenticationConfig(com.hazelcast.config.security.SimpleAuthenticationConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) KerberosAuthenticationConfig(com.hazelcast.config.security.KerberosAuthenticationConfig) RealmConfig(com.hazelcast.config.security.RealmConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) JetConfig(com.hazelcast.jet.config.JetConfig) FencedLockConfig(com.hazelcast.config.cp.FencedLockConfig) LdapAuthenticationConfig(com.hazelcast.config.security.LdapAuthenticationConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RealmConfig (com.hazelcast.config.security.RealmConfig)23 Test (org.junit.Test)18 QuickTest (com.hazelcast.test.annotation.QuickTest)16 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)12 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)11 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)11 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)10 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)10 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)9 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)9 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)9 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)9 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)9 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)7 JetConfig (com.hazelcast.jet.config.JetConfig)7 LoginModuleConfig (com.hazelcast.config.LoginModuleConfig)5 Config (com.hazelcast.config.Config)3 CredentialsFactoryConfig (com.hazelcast.config.CredentialsFactoryConfig)3 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)3 HashSet (java.util.HashSet)3