Search in sources :

Example 1 with ClientSecurityConfig

use of com.hazelcast.client.config.ClientSecurityConfig in project hazelcast by hazelcast.

the class ClientRegressionWithMockNetworkTest method testCredentials.

@Test
public void testCredentials() {
    final Config config = new Config();
    config.getGroupConfig().setName("foo").setPassword("bar");
    final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance(config);
    final ClientConfig clientConfig = new ClientConfig();
    final ClientSecurityConfig securityConfig = clientConfig.getSecurityConfig();
    securityConfig.setCredentialsClassname(MyCredentials.class.getName());
    final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) SerializationConfig(com.hazelcast.config.SerializationConfig) ClientSecurityConfig(com.hazelcast.client.config.ClientSecurityConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) ClientSecurityConfig(com.hazelcast.client.config.ClientSecurityConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with ClientSecurityConfig

use of com.hazelcast.client.config.ClientSecurityConfig in project hazelcast by hazelcast.

the class HazelcastClientInstanceImpl method initCredentials.

private Credentials initCredentials(ClientConfig config) {
    final GroupConfig groupConfig = config.getGroupConfig();
    final ClientSecurityConfig securityConfig = config.getSecurityConfig();
    Credentials c = securityConfig.getCredentials();
    if (c == null) {
        final String credentialsClassname = securityConfig.getCredentialsClassname();
        if (credentialsClassname != null) {
            try {
                c = ClassLoaderUtil.newInstance(config.getClassLoader(), credentialsClassname);
            } catch (Exception e) {
                throw ExceptionUtil.rethrow(e);
            }
        }
    }
    if (c == null) {
        c = new UsernamePasswordCredentials(groupConfig.getName(), groupConfig.getPassword());
    }
    return c;
}
Also used : GroupConfig(com.hazelcast.config.GroupConfig) ClientSecurityConfig(com.hazelcast.client.config.ClientSecurityConfig) UsernamePasswordCredentials(com.hazelcast.security.UsernamePasswordCredentials) Credentials(com.hazelcast.security.Credentials) TransactionException(com.hazelcast.transaction.TransactionException) UsernamePasswordCredentials(com.hazelcast.security.UsernamePasswordCredentials)

Aggregations

ClientSecurityConfig (com.hazelcast.client.config.ClientSecurityConfig)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 Config (com.hazelcast.config.Config)1 EvictionConfig (com.hazelcast.config.EvictionConfig)1 GroupConfig (com.hazelcast.config.GroupConfig)1 ListenerConfig (com.hazelcast.config.ListenerConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 SerializationConfig (com.hazelcast.config.SerializationConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Credentials (com.hazelcast.security.Credentials)1 UsernamePasswordCredentials (com.hazelcast.security.UsernamePasswordCredentials)1 NightlyTest (com.hazelcast.test.annotation.NightlyTest)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 TransactionException (com.hazelcast.transaction.TransactionException)1 Test (org.junit.Test)1