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