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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations