use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.
the class ClientCallbackHandler method handleCallback.
protected void handleCallback(Callback cb) throws UnsupportedCallbackException {
if (cb instanceof RealmConfigCallback) {
RealmConfigCallback realmCb = (RealmConfigCallback) cb;
RealmConfig realmCfg = null;
if (clientConfig != null && clientConfig.getSecurityConfig() != null) {
realmCfg = clientConfig.getSecurityConfig().getRealmConfig(realmCb.getRealmName());
}
realmCb.setRealmConfig(realmCfg);
} else {
throw new UnsupportedCallbackException(cb);
}
}
use of com.hazelcast.config.security.RealmConfig in project hazelcast by hazelcast.
the class AbstractClientConfigBuilderTest method testSecurityConfig.
@Test
public void testSecurityConfig() {
ClientSecurityConfig securityConfig = fullClientConfig.getSecurityConfig();
assertNull(securityConfig.getUsernamePasswordIdentityConfig());
CredentialsFactoryConfig credentialsFactoryConfig = securityConfig.getCredentialsFactoryConfig();
assertEquals("com.hazelcast.examples.MyCredentialsFactory", credentialsFactoryConfig.getClassName());
Properties properties = credentialsFactoryConfig.getProperties();
assertEquals("value", properties.getProperty("property"));
RealmConfig realmConfig = securityConfig.getRealmConfig("krb5Initiator");
assertNotNull(realmConfig);
JaasAuthenticationConfig jaasConf = realmConfig.getJaasAuthenticationConfig();
assertNotNull(jaasConf);
List<LoginModuleConfig> loginModuleConfigs = jaasConf.getLoginModuleConfigs();
assertNotNull(loginModuleConfigs);
assertEquals(1, loginModuleConfigs.size());
LoginModuleConfig loginModuleConfig = loginModuleConfigs.get(0);
assertEquals("com.sun.security.auth.module.Krb5LoginModule", loginModuleConfig.getClassName());
assertEquals(LoginModuleUsage.REQUIRED, loginModuleConfig.getUsage());
assertEquals("jduke@HAZELCAST.COM", loginModuleConfig.getProperties().get("principal"));
}
use of com.hazelcast.config.security.RealmConfig 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());
}
use of com.hazelcast.config.security.RealmConfig 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"));
}
use of com.hazelcast.config.security.RealmConfig 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());
}
Aggregations