org.apache.hc.client5.http.auth

## Class UsernamePasswordCredentials

- java.lang.Object
- - org.apache.hc.client5.http.auth.UsernamePasswordCredentials

- All Implemented Interfaces:
    Serializable, Credentials

      @Contract(threading=IMMUTABLE)
      public class UsernamePasswordCredentials
      extends Object
      implements Credentials, Serializable

  Simple `Credentials` representation based on a user name / password pair.
  Since:
    4.0
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UsernamePasswordCredentials(Principal principal, char[] password)` The constructor with the username and password arguments.
    `UsernamePasswordCredentials(String username, char[] password)` The constructor with the username and password arguments.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `char[]` | `getPassword()` Deprecated. Use `getUserPassword()`.
    `String` | `getUserName()`
    `char[]` | `getUserPassword()`
    `Principal` | `getUserPrincipal()`
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### UsernamePasswordCredentials

          public UsernamePasswordCredentials(Principal principal,
                                             char[] password)

      The constructor with the username and password arguments.
      Parameters:
        `principal` - the user principal
        `password` - the password
      Since:
        5.3
      See Also:
        `BasicUserPrincipal`, `NTUserPrincipal`

    - #### UsernamePasswordCredentials

          public UsernamePasswordCredentials(String username,
                                             char[] password)

      The constructor with the username and password arguments.
      Parameters:
        `username` - the user name
        `password` - the password

  - ### Method Detail

    - #### getUserPrincipal

          public Principal getUserPrincipal()

      Specified by:
        `getUserPrincipal` in interface `Credentials`

    - #### getUserName

          public String getUserName()

    - #### getUserPassword

          public char[] getUserPassword()

      Since:
        5.3

    - #### getPassword

          @Deprecated
          public char[] getPassword()

      Deprecated. Use `getUserPassword()`.
      Specified by:
        `getPassword` in interface `Credentials`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.