@ThreadSafe public abstract class PlainTextAuthProviderBase extends Object implements AuthProvider
This can be reused to write an implementation that retrieves the credentials from another source than the configuration.
| Modifier and Type | Class and Description |
|---|---|
static class |
PlainTextAuthProviderBase.Credentials |
protected static class |
PlainTextAuthProviderBase.PlainTextAuthenticator |
| Modifier | Constructor and Description |
|---|---|
protected |
PlainTextAuthProviderBase(String logPrefix) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
protected abstract PlainTextAuthProviderBase.Credentials |
getCredentials(EndPoint endPoint,
String serverAuthenticator)
Retrieves the credentials from the underlying source.
|
Authenticator |
newAuthenticator(EndPoint endPoint,
String serverAuthenticator)
The authenticator to use when connecting to
host. |
void |
onMissingChallenge(EndPoint endPoint)
What to do if the server does not send back an authentication challenge (in other words, lets
the client connect without any form of authentication).
|
protected PlainTextAuthProviderBase(@NonNull
String logPrefix)
logPrefix - a string that will get prepended to the logs (this is used for discrimination
when you have multiple driver instances executing in the same JVM). Built-in
implementations fill this with Session.getName().@NonNull protected abstract PlainTextAuthProviderBase.Credentials getCredentials(@NonNull EndPoint endPoint, @NonNull String serverAuthenticator)
This is invoked every time the driver opens a new connection.
@NonNull public Authenticator newAuthenticator(@NonNull EndPoint endPoint, @NonNull String serverAuthenticator) throws AuthenticationException
AuthProviderhost.newAuthenticator in interface AuthProviderendPoint - the Cassandra host to connect to.serverAuthenticator - the configured authenticator on the host.AuthenticationExceptionpublic void onMissingChallenge(@NonNull
EndPoint endPoint)
AuthProviderThis is suspicious because having authentication enabled on the client but not on the server is probably a configuration mistake.
Provider implementations are free to handle this however they want; typical approaches are:
AuthenticationException to abort the connection (but note that it
will be retried according to the ReconnectionPolicy).
onMissingChallenge in interface AuthProviderpublic void close()
close in interface AutoCloseableCopyright © 2017–2020. All rights reserved.