Search in sources :

Example 6 with JaasAuthenticationConfig

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

the class ClientConfigXmlGeneratorTest method kerberosIdentity.

@Test
public void kerberosIdentity() {
    KerberosIdentityConfig identityConfig = new KerberosIdentityConfig().setRealm("realm").setSecurityRealm("security-realm").setPrincipal("jduke").setKeytabFile("/opt/keytab").setServiceNamePrefix("prefix").setSpn("spn");
    RealmConfig realmConfig = new RealmConfig().setJaasAuthenticationConfig(new JaasAuthenticationConfig().addLoginModuleConfig(new LoginModuleConfig("test.Krb5LoginModule", LoginModuleUsage.REQUIRED).setProperty("principal", "jduke")));
    ClientSecurityConfig securityConfig = clientConfig.getSecurityConfig().setKerberosIdentityConfig(identityConfig).addRealmConfig("kerberos", realmConfig);
    ClientConfig actual = newConfigViaGenerator();
    assertEquals(securityConfig, actual.getSecurityConfig());
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) LoginModuleConfig(com.hazelcast.config.LoginModuleConfig) KerberosIdentityConfig(com.hazelcast.config.security.KerberosIdentityConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with JaasAuthenticationConfig

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

the class TestClientApplicationContext method testSecurityRealms.

@Test
public void testSecurityRealms() {
    assertNotNull(client5);
    RealmConfig realmConfig = client5.getClientConfig().getSecurityConfig().getRealmConfig("krb5Initiator");
    assertNotNull(realmConfig);
    JaasAuthenticationConfig jaasAuthenticationConfig = realmConfig.getJaasAuthenticationConfig();
    assertNotNull(jaasAuthenticationConfig);
    assertEquals(1, jaasAuthenticationConfig.getLoginModuleConfigs().size());
    LoginModuleConfig loginModuleConfig = jaasAuthenticationConfig.getLoginModuleConfigs().get(0);
    assertEquals("com.sun.security.auth.module.Krb5LoginModule", loginModuleConfig.getClassName());
    assertEquals("jduke@HAZELCAST.COM", loginModuleConfig.getProperties().getProperty("principal"));
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) LoginModuleConfig(com.hazelcast.config.LoginModuleConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with JaasAuthenticationConfig

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

the class SecureApplicationContextTest method testClientLoginConfigs.

@Test
public void testClientLoginConfigs() {
    RealmConfig realmConfig = securityConfig.getRealmConfig(securityConfig.getClientRealm());
    JaasAuthenticationConfig jaasAuthenticationConfig = realmConfig.getJaasAuthenticationConfig();
    assertNotNull(jaasAuthenticationConfig);
    List<LoginModuleConfig> list = jaasAuthenticationConfig.getLoginModuleConfigs();
    assertEquals(2, list.size());
    LoginModuleConfig lm1 = list.get(0);
    assertEquals("com.hazelcast.examples.MyOptionalLoginModule", lm1.getClassName());
    assertFalse(lm1.getProperties().isEmpty());
    assertEquals(LoginModuleUsage.OPTIONAL, lm1.getUsage());
    LoginModuleConfig lm2 = list.get(1);
    assertEquals("com.hazelcast.examples.MyRequiredLoginModule", lm2.getClassName());
    assertFalse(lm2.getProperties().isEmpty());
    assertEquals(LoginModuleUsage.REQUIRED, lm2.getUsage());
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) LoginModuleConfig(com.hazelcast.config.LoginModuleConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with JaasAuthenticationConfig

use of com.hazelcast.config.security.JaasAuthenticationConfig 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);
}
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) Properties(java.util.Properties) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)9 RealmConfig (com.hazelcast.config.security.RealmConfig)6 Test (org.junit.Test)6 LoginModuleConfig (com.hazelcast.config.LoginModuleConfig)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Node (org.w3c.dom.Node)3 CredentialsFactoryConfig (com.hazelcast.config.CredentialsFactoryConfig)2 KerberosIdentityConfig (com.hazelcast.config.security.KerberosIdentityConfig)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 Properties (java.util.Properties)2 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)1 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)1 FencedLockConfig (com.hazelcast.config.cp.FencedLockConfig)1 SemaphoreConfig (com.hazelcast.config.cp.SemaphoreConfig)1 KerberosAuthenticationConfig (com.hazelcast.config.security.KerberosAuthenticationConfig)1 LdapAuthenticationConfig (com.hazelcast.config.security.LdapAuthenticationConfig)1 SimpleAuthenticationConfig (com.hazelcast.config.security.SimpleAuthenticationConfig)1 TlsAuthenticationConfig (com.hazelcast.config.security.TlsAuthenticationConfig)1 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)1 YamlNode (com.hazelcast.internal.yaml.YamlNode)1