Class BasicAuthenticator

  • All Implemented Interfaces:
    Authenticator

    public class BasicAuthenticator
    extends AuthenticatorBase
    implements Authenticator
    This class implements support for Basic Authentication. The main purpose of this authenticator is to construct the Authorization header, and then add it to each outgoing REST API request.
    • Constructor Detail

      • BasicAuthenticator

        @Deprecated
        public BasicAuthenticator​(java.lang.String username,
                                  java.lang.String password)
        Deprecated.
        As of 9.7.0, use the Builder class instead.
        Construct a BasicAuthenticator instance with the specified username and password. These values are used to construct an Authorization header value that will be included in outgoing REST API requests.
        Parameters:
        username - the basic auth username
        password - the basic auth password
      • BasicAuthenticator

        @Deprecated
        public BasicAuthenticator​(java.util.Map<java.lang.String,​java.lang.String> config)
        Deprecated.
        As of 9.7.0, use BasicAuthenticator.fromConfiguration() instead.
        Construct a BasicAuthenticator using properties retrieved from the specified Map.
        Parameters:
        config - a map containing the username and password values
    • Method Detail

      • newBuilder

        public BasicAuthenticator.Builder newBuilder()
        Returns a new Builder instance pre-loaded with the configuration from "this".
        Returns:
        the builder
      • fromConfiguration

        public static BasicAuthenticator fromConfiguration​(java.util.Map<java.lang.String,​java.lang.String> config)
        Construct a BasicAuthenticator instance using properties retrieved from the specified Map.
        Parameters:
        config - a map containing the configuration properties
        Returns:
        the BasicAuthenticator instance
      • validate

        public void validate()
        Description copied from interface: Authenticator
        Validates the current set of configuration information in the Authenticator.
        Specified by:
        validate in interface Authenticator
      • authenticationType

        public java.lang.String authenticationType()
        Description copied from interface: Authenticator
        Returns the authentication type associated with the Authenticator instance.
        Specified by:
        authenticationType in interface Authenticator
        Returns:
        a string representing the authentication type (e.g. "iam", "basic", "icp4d", etc.)
      • getUsername

        public java.lang.String getUsername()
        Returns:
        the username configured on this Authenticator
      • getPassword

        public java.lang.String getPassword()
        Returns:
        the password configured on this Authenticator
      • authenticate

        public void authenticate​(okhttp3.Request.Builder builder)
        This method is called to authenticate an outgoing REST API request. Here, we'll just set the Authorization header to provide the necessary authentication info.
        Specified by:
        authenticate in interface Authenticator
        Parameters:
        builder - the Request.Builder instance to authenticate