Search in sources :

Example 6 with CredentialsFactoryConfig

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

the class YamlClientConfigBuilderTest method testSecurityConfig_onlyFactory.

@Override
@Test
public void testSecurityConfig_onlyFactory() {
    String yaml = "" + "hazelcast-client:\n" + "  security:\n" + "    credentials-factory:\n" + "      class-name: com.hazelcast.examples.MyCredentialsFactory\n" + "      properties:\n" + "        property: value";
    ClientConfig config = buildConfig(yaml);
    ClientSecurityConfig securityConfig = config.getSecurityConfig();
    CredentialsFactoryConfig credentialsFactoryConfig = securityConfig.getCredentialsFactoryConfig();
    assertEquals("com.hazelcast.examples.MyCredentialsFactory", credentialsFactoryConfig.getClassName());
    Properties properties = credentialsFactoryConfig.getProperties();
    assertEquals("value", properties.getProperty("property"));
}
Also used : CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) Properties(java.util.Properties) QuickTest(com.hazelcast.test.annotation.QuickTest) YamlConfigBuilderTest(com.hazelcast.config.YamlConfigBuilderTest) Test(org.junit.Test)

Example 7 with CredentialsFactoryConfig

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

the class XmlClientConfigBuilderTest method testSecurityConfig_onlyFactory.

@Override
@Test
public void testSecurityConfig_onlyFactory() {
    String xml = HAZELCAST_CLIENT_START_TAG + "  <security>\n" + "        <credentials-factory class-name=\"com.hazelcast.examples.MyCredentialsFactory\">\n" + "            <properties>\n" + "                <property name=\"property\">value</property>\n" + "            </properties>\n" + "        </credentials-factory>\n" + "    </security>" + HAZELCAST_CLIENT_END_TAG;
    ClientConfig config = buildConfig(xml);
    ClientSecurityConfig securityConfig = config.getSecurityConfig();
    CredentialsFactoryConfig credentialsFactoryConfig = securityConfig.getCredentialsFactoryConfig();
    assertEquals("com.hazelcast.examples.MyCredentialsFactory", credentialsFactoryConfig.getClassName());
    Properties properties = credentialsFactoryConfig.getProperties();
    assertEquals("value", properties.getProperty("property"));
}
Also used : CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) Properties(java.util.Properties) QuickTest(com.hazelcast.test.annotation.QuickTest) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest) Test(org.junit.Test)

Example 8 with CredentialsFactoryConfig

use of com.hazelcast.config.CredentialsFactoryConfig 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"));
}
Also used : RealmConfig(com.hazelcast.config.security.RealmConfig) CredentialsFactoryConfig(com.hazelcast.config.CredentialsFactoryConfig) LoginModuleConfig(com.hazelcast.config.LoginModuleConfig) Properties(java.util.Properties) JaasAuthenticationConfig(com.hazelcast.config.security.JaasAuthenticationConfig) Test(org.junit.Test) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest)

Example 9 with CredentialsFactoryConfig

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

the class MemberDomConfigProcessor method handleCredentialsFactory.

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

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