org.apache.http.client

## Interface AuthenticationStrategy

- All Known Implementing Classes:
    ProxyAuthenticationStrategy, TargetAuthenticationStrategy

      public interface AuthenticationStrategy

  /** A handler for determining if an HTTP response represents an authentication challenge that was sent back to the client as a result of authentication failure.

  Implementations of this interface must be thread-safe. Access to shared data must be synchronized as methods of this interface may be executed from multiple threads.

  Since:
    4.2

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `authFailed(org.apache.http.HttpHost authhost, AuthScheme authScheme, org.apache.http.protocol.HttpContext context)` Callback invoked in case of unsuccessful authentication.
    `void` | `authSucceeded(org.apache.http.HttpHost authhost, AuthScheme authScheme, org.apache.http.protocol.HttpContext context)` Callback invoked in case of successful authentication.
    `Map<String,org.apache.http.Header>` | `getChallenges(org.apache.http.HttpHost authhost, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context)` Extracts from the given HTTP response a collection of authentication challenges, each of which represents an authentication scheme supported by the authentication host.
    `boolean` | `isAuthenticationRequested(org.apache.http.HttpHost authhost, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context)` Determines if the given HTTP response response represents an authentication challenge that was sent back as a result of authentication failure.
    `Queue<AuthOption>` | `select(Map<String,org.apache.http.Header> challenges, org.apache.http.HttpHost authhost, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context)` Selects one authentication challenge out of all available and creates and generates `AuthOption` instance capable of processing that challenge.

- - ### Method Detail

    - #### isAuthenticationRequested

          boolean isAuthenticationRequested(org.apache.http.HttpHost authhost,
                                          org.apache.http.HttpResponse response,
                                          org.apache.http.protocol.HttpContext context)

      Determines if the given HTTP response response represents an authentication challenge that was sent back as a result of authentication failure.
      Parameters:
        `authhost` - authentication host.
        `response` - HTTP response.
        `context` - HTTP context.
      Returns:
        `true` if user authentication is required, `false` otherwise.

    - #### getChallenges

          Map<String,org.apache.http.Header> getChallenges(org.apache.http.HttpHost authhost,
                                                         org.apache.http.HttpResponse response,
                                                         org.apache.http.protocol.HttpContext context)
                                                           throws MalformedChallengeException

      Extracts from the given HTTP response a collection of authentication challenges, each of which represents an authentication scheme supported by the authentication host.
      Parameters:
        `authhost` - authentication host.
        `response` - HTTP response.
        `context` - HTTP context.
      Returns:
        a collection of challenges keyed by names of corresponding authentication schemes.
      Throws:
        `MalformedChallengeException` - if one of the authentication challenges is not valid or malformed.

    - #### select

          Queue<AuthOption> select(Map<String,org.apache.http.Header> challenges,
                                 org.apache.http.HttpHost authhost,
                                 org.apache.http.HttpResponse response,
                                 org.apache.http.protocol.HttpContext context)
                                   throws MalformedChallengeException

      Selects one authentication challenge out of all available and creates and generates `AuthOption` instance capable of processing that challenge.
      Parameters:
        `challenges` - collection of challenges.
        `authhost` - authentication host.
        `response` - HTTP response.
        `context` - HTTP context.
      Returns:
        authentication auth schemes that can be used for authentication. Can be empty.
      Throws:
        `MalformedChallengeException` - if one of the authentication challenges is not valid or malformed.

    - #### authSucceeded

          void authSucceeded(org.apache.http.HttpHost authhost,
                           AuthScheme authScheme,
                           org.apache.http.protocol.HttpContext context)

      Callback invoked in case of successful authentication.
      Parameters:
        `authhost` - authentication host.
        `authScheme` - authentication scheme used.
        `context` - HTTP context.

    - #### authFailed

          void authFailed(org.apache.http.HttpHost authhost,
                        AuthScheme authScheme,
                        org.apache.http.protocol.HttpContext context)

      Callback invoked in case of unsuccessful authentication.
      Parameters:
        `authhost` - authentication host.
        `authScheme` - authentication scheme used.
        `context` - HTTP context.

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