public interface Authenticator
Each time a new connection is created and the server requires authentication, a new instance
of this class will be created by the corresponding
AuthProvider to handle that
authentication. The lifecycle of that new
Authenticator will be:
initialResponse()method will be called. The initial return value will be sent to the server to initiate the handshake.
evaluateChallenge(java.nio.ByteBuffer)method will be called to produce a response that will be sent to the server. This challenge/response negotiation will continue until the server responds that authentication is successful (or an
onAuthenticationSuccess(java.nio.ByteBuffer)method will be called with the last information that the server may optionally have sent.
Note that, since the methods in this interface will be invoked on a driver I/O thread, they
all return asynchronous results. If your implementation performs heavy computations or blocking
calls, you'll want to schedule them on a separate executor, and return a
that represents their future completion. If your implementation is fast, lightweight and does not
perform blocking operations, it might be acceptable to run it on I/O threads directly; in that
SyncAuthenticator instead of this interface.
|Modifier and Type||Method and Description|
Evaluate a challenge received from the server.
Obtain an initial response token for initializing the SASL handshake.
Called when authentication is successful with the last information optionally sent by the server.
@NonNull CompletionStage<ByteBuffer> initialResponse()
null). Note that, if the returned byte buffer is writable, the driver will clear its contents immediately after use (to avoid keeping sensitive information in memory); do not reuse the same buffer across multiple invocations. Alternatively, if the contents are not sensitive, you can make the buffer read-only and safely reuse it.
@NonNull CompletionStage<ByteBuffer> evaluateChallenge(@Nullable ByteBuffer challenge)
challenge- the server's SASL challenge.
@NonNull CompletionStage<Void> onAuthenticationSuccess(@Nullable ByteBuffer token)
token- the information sent by the server with the authentication successful message. This will be
nullif the server sends no particular information on authentication success.
Copyright © 2017–2019. All rights reserved.