Search in sources :

Example 1 with Credentials

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);
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) Credentials(com.hazelcast.security.Credentials)

Example 2 with 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()));
        }
    }
}
Also used : LoginContext(javax.security.auth.login.LoginContext) LoginException(javax.security.auth.login.LoginException) Credentials(com.hazelcast.security.Credentials)

Example 3 with Credentials

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);
}
Also used : JoinRequest(com.hazelcast.internal.cluster.impl.JoinRequest) Credentials(com.hazelcast.security.Credentials)

Example 4 with Credentials

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

Credentials (com.hazelcast.security.Credentials)4 ClientSecurityConfig (com.hazelcast.client.config.ClientSecurityConfig)1 GroupConfig (com.hazelcast.config.GroupConfig)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 JoinRequest (com.hazelcast.internal.cluster.impl.JoinRequest)1 UsernamePasswordCredentials (com.hazelcast.security.UsernamePasswordCredentials)1 TransactionException (com.hazelcast.transaction.TransactionException)1 LoginContext (javax.security.auth.login.LoginContext)1 LoginException (javax.security.auth.login.LoginException)1