use of com.hazelcast.security.Credentials in project hazelcast by hazelcast.
the class AbstractMessageTask method initializeAndProcessMessage.
private void initializeAndProcessMessage() throws Throwable {
if (!node.getNodeExtension().isStartCompleted()) {
throw new HazelcastInstanceNotActiveException("Hazelcast instance is not ready yet!");
}
parameters = decodeClientMessage(clientMessage);
Credentials credentials = endpoint.getCredentials();
interceptBefore(credentials);
checkPermissions(endpoint);
processMessage();
interceptAfter(credentials);
}
use of com.hazelcast.security.Credentials in project hazelcast by hazelcast.
the class ClusterJoinManager method secureLogin.
private void secureLogin(JoinRequest joinRequest) {
if (node.securityContext != null) {
Credentials credentials = joinRequest.getCredentials();
if (credentials == null) {
throw new SecurityException("Expecting security credentials, but credentials could not be found in join request");
}
try {
LoginContext loginContext = node.securityContext.createMemberLoginContext(credentials);
loginContext.login();
} catch (LoginException e) {
throw new SecurityException(format("Authentication has failed for %s@%s, cause: %s", credentials.getPrincipal(), credentials.getEndpoint(), e.getMessage()));
}
}
}
use of com.hazelcast.security.Credentials in project hazelcast by hazelcast.
the class Node method createJoinRequest.
public JoinRequest createJoinRequest(boolean withCredentials) {
final Credentials credentials = (withCredentials && securityContext != null) ? securityContext.getCredentialsFactory().newCredentials() : null;
final Set<String> excludedMemberUuids = nodeExtension.getInternalHotRestartService().getExcludedMemberUuids();
return new JoinRequest(Packet.VERSION, buildInfo.getBuildNumber(), version, address, localMember.getUuid(), localMember.isLiteMember(), createConfigCheck(), credentials, localMember.getAttributes(), excludedMemberUuids);
}
use of com.hazelcast.security.Credentials 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