Package com.couchbase.client.core.env
Class PasswordAuthenticator
java.lang.Object
com.couchbase.client.core.env.PasswordAuthenticator
- All Implemented Interfaces:
Authenticator
Performs authentication against a Couchbase server cluster using username and password.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classProvides customization to thePasswordAuthenticator. -
Method Summary
Modifier and TypeMethodDescriptionvoidauthKeyValueConnection(EndpointContext ctx, com.couchbase.client.core.deps.io.netty.channel.ChannelPipeline pipeline) Allows the authenticator to add KV handlers during connection bootstrap to perform authentication.builder()Deprecated.Please use one of the "See Also" methods instead, to ensure all required builder properties are set.Creates a builder for an authenticator that uses the given credentials.builder(Supplier<UsernameAndPassword> supplier) Deprecated.This method is difficult to use safely, because it's easy to accidentally do blocking IO inside the supplier.static PasswordAuthenticatorCreates a new password authenticator with the default settings.Returns the value of the Authorization header to apply to HTTP requests, or null if no header should be applied.static PasswordAuthenticatorldapCompatible(String username, String password) Creates an LDAP compatible password authenticator which is INSECURE if not used with TLS.booleantoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.couchbase.client.core.env.Authenticator
applyTlsProperties, authHttpRequest, getSingleStepSaslAuthParameters
-
Method Details
-
builder
Deprecated.Please use one of the "See Also" methods instead, to ensure all required builder properties are set.Creates a newPasswordAuthenticator.Builderwhich allows to customize this authenticator.- See Also:
-
builder
Creates a builder for an authenticator that uses the given credentials. -
builder
@Deprecated public static PasswordAuthenticator.Builder builder(Supplier<UsernameAndPassword> supplier) Deprecated.This method is difficult to use safely, because it's easy to accidentally do blocking IO inside the supplier. Please usecluster.authenticator(newAuthenticator)instead.Creates a builder for an authenticator that uses dynamic credentials. This enables updating credentials without having to restart your application.IMPORTANT: The supplier's
get()method must not do blocking IO. It is called from async contexts, where blocking IO can starve important SDK resources like async event loops.Instead of blocking inside the supplier, the supplier should return a value from a volatile field.
One way to keep the supplier's value up to date is to schedule a recurring task that reads new credentials from an external source and stores them in the volatile field.
-
create
Creates a new password authenticator with the default settings.- Parameters:
username- the username to use for all authentication.password- the password to use alongside the username.- Returns:
- the instantiated
PasswordAuthenticator. - See Also:
-
ldapCompatible
Creates an LDAP compatible password authenticator which is INSECURE if not used with TLS.Please note that this is INSECURE and will leak user credentials on the wire to eavesdroppers. This should only be enabled in trusted environments.
- Parameters:
username- the username to use for all authentication.password- the password to use alongside the username.- Returns:
- the instantiated
PasswordAuthenticator.
-
getAuthHeaderValue
Description copied from interface:AuthenticatorReturns the value of the Authorization header to apply to HTTP requests, or null if no header should be applied.- Specified by:
getAuthHeaderValuein interfaceAuthenticator
-
authKeyValueConnection
public void authKeyValueConnection(EndpointContext ctx, com.couchbase.client.core.deps.io.netty.channel.ChannelPipeline pipeline) Description copied from interface:AuthenticatorAllows the authenticator to add KV handlers during connection bootstrap to perform authentication.- Specified by:
authKeyValueConnectionin interfaceAuthenticator- Parameters:
ctx- the endpoint context.pipeline- the pipeline when the endpoint is constructed.
-
requiresTls
public boolean requiresTls()- Specified by:
requiresTlsin interfaceAuthenticator
-
toString
-