use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.
the class ConfigXmlGeneratorTest method testTlsAuthenticationConfig.
@Test
public void testTlsAuthenticationConfig() {
Config cfg = new Config();
RealmConfig realmConfig = new RealmConfig().setTlsAuthenticationConfig(new TlsAuthenticationConfig().setRoleAttribute("roleAttribute"));
SecurityConfig expectedConfig = new SecurityConfig().setClientRealmConfig("tlsRealm", 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 testSecurityConfig.
@Test
public void testSecurityConfig() {
Config cfg = new Config();
Properties dummyprops = new Properties();
dummyprops.put("a", "b");
RealmConfig memberRealm = new RealmConfig().setJaasAuthenticationConfig(new JaasAuthenticationConfig().setLoginModuleConfigs(Arrays.asList(new LoginModuleConfig().setClassName("member.f.o.o").setUsage(LoginModuleConfig.LoginModuleUsage.OPTIONAL), new LoginModuleConfig().setClassName("member.b.a.r").setUsage(LoginModuleConfig.LoginModuleUsage.SUFFICIENT), new LoginModuleConfig().setClassName("member.l.o.l").setUsage(LoginModuleConfig.LoginModuleUsage.REQUIRED)))).setCredentialsFactoryConfig(new CredentialsFactoryConfig().setClassName("foo.bar").setProperties(dummyprops));
SecurityConfig expectedConfig = new SecurityConfig();
expectedConfig.setEnabled(true).setOnJoinPermissionOperation(OnJoinPermissionOperationName.NONE).setClientBlockUnmappedActions(false).setClientRealmConfig("cr", new RealmConfig().setJaasAuthenticationConfig(new JaasAuthenticationConfig().setLoginModuleConfigs(Arrays.asList(new LoginModuleConfig().setClassName("f.o.o").setUsage(LoginModuleConfig.LoginModuleUsage.OPTIONAL), new LoginModuleConfig().setClassName("b.a.r").setUsage(LoginModuleConfig.LoginModuleUsage.SUFFICIENT), new LoginModuleConfig().setClassName("l.o.l").setUsage(LoginModuleConfig.LoginModuleUsage.REQUIRED)))).setUsernamePasswordIdentityConfig("username", "password")).setMemberRealmConfig("mr", memberRealm).setClientPermissionConfigs(new HashSet<>(asList(new PermissionConfig().setActions(newHashSet("read", "remove")).setEndpoints(newHashSet("127.0.0.1", "127.0.0.2")).setType(PermissionConfig.PermissionType.ATOMIC_LONG).setName("mycounter").setPrincipal("devos"), new PermissionConfig().setType(PermissionConfig.PermissionType.MANAGEMENT).setPrincipal("mcadmin"), new PermissionConfig().setType(PermissionConfig.PermissionType.CONFIG), new PermissionConfig().setActions(newHashSet("read", "create")).setType(PermissionConfig.PermissionType.REPLICATEDMAP).setName("rmap").setPrincipal("monitor"))));
cfg.setSecurityConfig(expectedConfig);
SecurityConfig actualConfig = getNewConfigViaXMLGenerator(cfg, false).getSecurityConfig();
assertEquals(expectedConfig, actualConfig);
}
use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.
the class ConfigXmlGeneratorTest method testKerberosConfig.
@Test
public void testKerberosConfig() {
Config cfg = new Config();
RealmConfig realmConfig = new RealmConfig().setKerberosAuthenticationConfig(new KerberosAuthenticationConfig().setSkipIdentity(TRUE).setSkipEndpoint(FALSE).setSkipRole(TRUE).setRelaxFlagsCheck(TRUE).setUseNameWithoutRealm(TRUE).setSecurityRealm("jaasRealm").setKeytabFile("/opt/test.keytab").setPrincipal("testPrincipal").setLdapAuthenticationConfig(new LdapAuthenticationConfig().setUrl("url"))).setKerberosIdentityConfig(new KerberosIdentityConfig().setRealm("HAZELCAST.COM").setSecurityRealm("krb5Init").setKeytabFile("/opt/test.keytab").setPrincipal("testPrincipal").setServiceNamePrefix("hz/").setUseCanonicalHostname(TRUE).setSpn("spn@HAZELCAST.COM"));
SecurityConfig expectedConfig = new SecurityConfig().setMemberRealmConfig("kerberosRealm", realmConfig);
cfg.setSecurityConfig(expectedConfig);
SecurityConfig actualConfig = getNewConfigViaXMLGenerator(cfg).getSecurityConfig();
assertEquals(expectedConfig, actualConfig);
}
Aggregations