Class BasicAuthClientCredentials

java.lang.Object
com.helger.http.basicauth.BasicAuthClientCredentials

@Immutable public class BasicAuthClientCredentials extends Object
Credentials for HTTP basic authentication
Author:
Philip Helger
  • Constructor Details

    • BasicAuthClientCredentials

      public BasicAuthClientCredentials(@Nonnull @Nonempty String sUserName)
      Create credentials with a user name only and no password.
      Parameters:
      sUserName - The user name to use. May neither be null nor empty.
    • BasicAuthClientCredentials

      public BasicAuthClientCredentials(@Nonnull @Nonempty String sUserName, @Nullable String sPassword)
      Create credentials with a user name and a password.
      Parameters:
      sUserName - The user name to use. May neither be null nor empty.
      sPassword - The password to use. May be null or empty to indicate that no password is present.
  • Method Details

    • getUserName

      @Nonnull @Nonempty public String getUserName()
      Returns:
      The user name. Neither null nor empty.
    • getPassword

      @Nullable public String getPassword()
      Returns:
      The password. May be null or empty.
    • hasPassword

      public boolean hasPassword()
      Returns:
      true if a non-null non-empty password is present.
    • getRequestValue

      @Nonnull @Nonempty public String getRequestValue()
      Create the request HTTP header value for use with the CHttpHeader.AUTHORIZATION header name.
      Returns:
      The HTTP header value to use. Neither null nor empty.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object