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);
}
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;
}
Aggregations