org.apache.hc.client5.testing.auth

## Class BasicAuthenticationHandler

- java.lang.Object
- - org.apache.hc.client5.testing.auth.BasicAuthenticationHandler

- All Implemented Interfaces:
    AuthenticationHandler<String>

      public class BasicAuthenticationHandler
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicAuthenticationHandler()` Constructs a new BasicAuthenticationHandler with UTF-8 as the charset.
    `BasicAuthenticationHandler(Charset charset)` Deprecated. This constructor is deprecated to enforce the use of `StandardCharsets.UTF_8` encoding in compliance with RFC 7617 for HTTP Basic Authentication. Use the default constructor `BasicAuthenticationHandler()` instead.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `challenge(List<org.apache.hc.core5.http.NameValuePair> params)`
    `String` | `extractAuthToken(String challengeResponse)`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BasicAuthenticationHandler

          @Deprecated
          public BasicAuthenticationHandler(Charset charset)

      Deprecated. This constructor is deprecated to enforce the use of `StandardCharsets.UTF_8` encoding in compliance with RFC 7617 for HTTP Basic Authentication. Use the default constructor `BasicAuthenticationHandler()` instead.
      Parameters:
        `charset` - the `Charset` set to be used for encoding credentials. This parameter is ignored as UTF-8 is always used.
      Since:
        5.3

    - #### BasicAuthenticationHandler

          public BasicAuthenticationHandler()

      Constructs a new BasicAuthenticationHandler with UTF-8 as the charset. This default setting aligns with standard practices for encoding credentials in Basic Authentication.

  - ### Method Detail

    - #### challenge

          public final String challenge(List<org.apache.hc.core5.http.NameValuePair> params)

      Specified by:
        `challenge` in interface `AuthenticationHandler<String>`

    - #### extractAuthToken

          public final String extractAuthToken(String challengeResponse)
                                        throws org.apache.hc.core5.http.HttpException

      Specified by:
        `extractAuthToken` in interface `AuthenticationHandler<String>`
      Throws:
        `org.apache.hc.core5.http.HttpException`

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