Search in sources :

Example 1 with TokenCredentials

use of com.hazelcast.security.TokenCredentials in project hazelcast by hazelcast.

the class TcpClientConnectionManager method encodeAuthenticationRequest.

private ClientMessage encodeAuthenticationRequest(Address toAddress) {
    InternalSerializationService ss = client.getSerializationService();
    byte serializationVersion = ss.getVersion();
    CandidateClusterContext currentContext = clusterDiscoveryService.current();
    Credentials credentials = currentContext.getCredentialsFactory().newCredentials(toAddress);
    String clusterName = currentContext.getClusterName();
    currentCredentials = credentials;
    if (credentials instanceof PasswordCredentials) {
        PasswordCredentials cr = (PasswordCredentials) credentials;
        return ClientAuthenticationCodec.encodeRequest(clusterName, cr.getName(), cr.getPassword(), clientUuid, connectionType, serializationVersion, BuildInfoProvider.getBuildInfo().getVersion(), client.getName(), labels);
    } else {
        byte[] secretBytes;
        if (credentials instanceof TokenCredentials) {
            secretBytes = ((TokenCredentials) credentials).getToken();
        } else {
            secretBytes = ss.toData(credentials).toByteArray();
        }
        return ClientAuthenticationCustomCodec.encodeRequest(clusterName, secretBytes, clientUuid, connectionType, serializationVersion, BuildInfoProvider.getBuildInfo().getVersion(), client.getName(), labels);
    }
}
Also used : CandidateClusterContext(com.hazelcast.client.impl.clientside.CandidateClusterContext) PasswordCredentials(com.hazelcast.security.PasswordCredentials) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) TokenCredentials(com.hazelcast.security.TokenCredentials) PasswordCredentials(com.hazelcast.security.PasswordCredentials) Credentials(com.hazelcast.security.Credentials) TokenCredentials(com.hazelcast.security.TokenCredentials)

Aggregations

CandidateClusterContext (com.hazelcast.client.impl.clientside.CandidateClusterContext)1 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 Credentials (com.hazelcast.security.Credentials)1 PasswordCredentials (com.hazelcast.security.PasswordCredentials)1 TokenCredentials (com.hazelcast.security.TokenCredentials)1