Search in sources :

Example 1 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig in project hazelcast by hazelcast.

the class SecureApplicationContextTest method testMemberRealm.

@Test
public void testMemberRealm() {
    RealmConfig realmConfig = securityConfig.getRealmConfig(securityConfig.getMemberRealm());
    JaasAuthenticationConfig jaasAuthenticationConfig = realmConfig.getJaasAuthenticationConfig();
    assertNotNull(jaasAuthenticationConfig);
    List<LoginModuleConfig> list = jaasAuthenticationConfig.getLoginModuleConfigs();
    assertEquals(1, list.size());
    LoginModuleConfig lm = list.get(0);
    assertEquals("com.hazelcast.examples.MyRequiredLoginModule", lm.getClassName());
    assertFalse(lm.getProperties().isEmpty());
    assertEquals(LoginModuleUsage.REQUIRED, lm.getUsage());
    CredentialsFactoryConfig credentialsFactoryConfig = realmConfig.getCredentialsFactoryConfig();
    assertNotNull(credentialsFactoryConfig);
    assertEquals(dummyCredentialsFactory, credentialsFactoryConfig.getImplementation());
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) LoginModuleConfig(com.hazelcast.config.LoginModuleConfig) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig in project hazelcast by hazelcast.

the class ClientConfigXmlGenerator method security.

private static void security(XmlGenerator gen, ClientSecurityConfig security) {
    if (security == null) {
        return;
    }
    gen.open("security");
    UsernamePasswordIdentityConfig upConfig = security.getUsernamePasswordIdentityConfig();
    if (upConfig != null) {
        gen.node("username-password", null, "username", upConfig.getUsername(), "password", upConfig.getPassword());
    }
    TokenIdentityConfig tic = security.getTokenIdentityConfig();
    if (tic != null) {
        gen.node("token", tic.getTokenEncoded(), "encoding", tic.getEncoding());
    }
    CredentialsFactoryConfig cfConfig = security.getCredentialsFactoryConfig();
    if (cfConfig != null) {
        gen.open("credentials-factory", "class-name", cfConfig.getClassName()).appendProperties(cfConfig.getProperties()).close();
    }
    kerberosIdentityGenerator(gen, security.getKerberosIdentityConfig());
    Map<String, RealmConfig> realms = security.getRealmConfigs();
    if (realms != null && !realms.isEmpty()) {
        gen.open("realms");
        for (Map.Entry<String, RealmConfig> realmEntry : realms.entrySet()) {
            securityRealmGenerator(gen, realmEntry.getKey(), realmEntry.getValue());
        }
        gen.close();
    }
    gen.close();
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) UsernamePasswordIdentityConfig(com.hazelcast.config.security.UsernamePasswordIdentityConfig) CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) TokenIdentityConfig(com.hazelcast.config.security.TokenIdentityConfig) Map(java.util.Map)

Example 3 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig in project hazelcast by hazelcast.

the class ClientDomConfigProcessor method handleCredentialsFactory.

private void handleCredentialsFactory(Node node, ClientSecurityConfig clientSecurityConfig) {
    Node classNameNode = getNamedItemNode(node, "class-name");
    String className = getTextContent(classNameNode);
    CredentialsFactoryConfig credentialsFactoryConfig = new CredentialsFactoryConfig(className);
    clientSecurityConfig.setCredentialsFactoryConfig(credentialsFactoryConfig);
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("properties", nodeName)) {
            fillProperties(child, credentialsFactoryConfig.getProperties());
            break;
        }
    }
}
Also used : CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) Node(org.w3c.dom.Node)

Example 4 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig in project hazelcast by hazelcast.

the class FailoverConfigTest method testClientConfigWith_withAValidChange.

@Test
public void testClientConfigWith_withAValidChange() {
    ClientFailoverConfig clientFailoverConfig = new ClientFailoverConfig();
    clientFailoverConfig.addClientConfig(new ClientConfig());
    ClientConfig alternativeConfig = new ClientConfig();
    alternativeConfig.setClusterName("alternative");
    CredentialsFactoryConfig credentialsFactoryConfig = new CredentialsFactoryConfig();
    credentialsFactoryConfig.setClassName("CustomCredentials");
    alternativeConfig.getSecurityConfig().setCredentialsFactoryConfig(credentialsFactoryConfig);
    clientFailoverConfig.addClientConfig(alternativeConfig);
    resolveClientFailoverConfig(clientFailoverConfig);
}
Also used : CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) ClientFailoverConfig(com.hazelcast.client.config.ClientFailoverConfig) FailoverClientConfigSupport.resolveClientFailoverConfig(com.hazelcast.client.impl.clientside.FailoverClientConfigSupport.resolveClientFailoverConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method credentialsFactory.

@Test
public void credentialsFactory() {
    Properties props = new Properties();
    props.setProperty("foo", "bar");
    CredentialsFactoryConfig identityConfig = new CredentialsFactoryConfig("com.test.CFactory");
    clientConfig.getSecurityConfig().setCredentialsFactoryConfig(identityConfig);
    ClientConfig actual = newConfigViaGenerator();
    assertEquals(identityConfig, actual.getSecurityConfig().getCredentialsFactoryConfig());
}
Also used : CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) Properties(java.util.Properties) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

CredentialsFactoryConfig (com.hazelcast.config.CredentialsFactoryConfig)9 Test (org.junit.Test)6 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Properties (java.util.Properties)4 RealmConfig (com.hazelcast.config.security.RealmConfig)3 LoginModuleConfig (com.hazelcast.config.LoginModuleConfig)2 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)2 JaasAuthenticationConfig (com.hazelcast.config.security.JaasAuthenticationConfig)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 Node (org.w3c.dom.Node)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ClientFailoverConfig (com.hazelcast.client.config.ClientFailoverConfig)1 FailoverClientConfigSupport.resolveClientFailoverConfig (com.hazelcast.client.impl.clientside.FailoverClientConfigSupport.resolveClientFailoverConfig)1 YamlConfigBuilderTest (com.hazelcast.config.YamlConfigBuilderTest)1 TokenIdentityConfig (com.hazelcast.config.security.TokenIdentityConfig)1 UsernamePasswordIdentityConfig (com.hazelcast.config.security.UsernamePasswordIdentityConfig)1 Map (java.util.Map)1