org.apache.hc.client5.http.impl.auth

## Class HttpAuthenticator

- java.lang.Object
- - org.apache.hc.client5.http.impl.auth.HttpAuthenticator

-     @Contract(threading=STATELESS)
      public final class HttpAuthenticator
      extends Object

  Utility class that implements commons aspects of the client side HTTP authentication.
  Since:
    4.3

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpAuthenticator()`
    `HttpAuthenticator(org.slf4j.Logger log)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addAuthResponse(org.apache.hc.core5.http.HttpHost host, ChallengeType challengeType, org.apache.hc.core5.http.HttpRequest request, AuthExchange authExchange, org.apache.hc.core5.http.protocol.HttpContext context)` Generates a response to the authentication challenge based on the actual `AuthExchange` state and adds it to the given `HttpRequest` message .
    `boolean` | `isChallenged(org.apache.hc.core5.http.HttpHost host, ChallengeType challengeType, org.apache.hc.core5.http.HttpResponse response, AuthExchange authExchange, org.apache.hc.core5.http.protocol.HttpContext context)` Determines whether the given response represents an authentication challenge.
    `boolean` | `updateAuthState(org.apache.hc.core5.http.HttpHost host, ChallengeType challengeType, org.apache.hc.core5.http.HttpResponse response, AuthenticationStrategy authStrategy, AuthExchange authExchange, org.apache.hc.core5.http.protocol.HttpContext context)` Updates the `AuthExchange` state based on the challenge presented in the response message using the given `AuthenticationStrategy`.

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

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

- - ### Constructor Detail

    - #### HttpAuthenticator

          @Internal
          public HttpAuthenticator(org.slf4j.Logger log)

    - #### HttpAuthenticator

          public HttpAuthenticator()

  - ### Method Detail

    - #### isChallenged

          public boolean isChallenged(org.apache.hc.core5.http.HttpHost host,
                             ChallengeType challengeType,
                             org.apache.hc.core5.http.HttpResponse response,
                             AuthExchange authExchange,
                             org.apache.hc.core5.http.protocol.HttpContext context)

      Determines whether the given response represents an authentication challenge.
      Parameters:
        `host` - the hostname of the opposite endpoint.
        `challengeType` - the challenge type (target or proxy).
        `response` - the response message head.
        `authExchange` - the current authentication exchange state.
        `context` - the current execution context.
      Returns:
        `true` if the response message represents an authentication challenge, `false` otherwise.

    - #### updateAuthState

          public boolean updateAuthState(org.apache.hc.core5.http.HttpHost host,
                                ChallengeType challengeType,
                                org.apache.hc.core5.http.HttpResponse response,
                                AuthenticationStrategy authStrategy,
                                AuthExchange authExchange,
                                org.apache.hc.core5.http.protocol.HttpContext context)

      Updates the `AuthExchange` state based on the challenge presented in the response message using the given `AuthenticationStrategy`.
      Parameters:
        `host` - the hostname of the opposite endpoint.
        `challengeType` - the challenge type (target or proxy).
        `response` - the response message head.
        `authStrategy` - the authentication strategy.
        `authExchange` - the current authentication exchange state.
        `context` - the current execution context.
      Returns:
        `true` if the authentication state has been updated, `false` if unchanged.

    - #### addAuthResponse

          public void addAuthResponse(org.apache.hc.core5.http.HttpHost host,
                             ChallengeType challengeType,
                             org.apache.hc.core5.http.HttpRequest request,
                             AuthExchange authExchange,
                             org.apache.hc.core5.http.protocol.HttpContext context)

      Generates a response to the authentication challenge based on the actual `AuthExchange` state and adds it to the given `HttpRequest` message .
      Parameters:
        `host` - the hostname of the opposite endpoint.
        `challengeType` - the challenge type (target or proxy).
        `request` - the request message head.
        `authExchange` - the current authentication exchange state.
        `context` - the current execution context.

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