Top Description Fields Constructors Methods
org.apache.hc.client5.http.impl.auth

public final Class HttpAuthenticator

extends Object
Class Inheritance
Annotations
@Contract
threading:STATELESS
Imports
java.util.HashMap, .LinkedList, .List, .Locale, .Map, .Queue, org.apache.hc.client5.http.AuthenticationStrategy, org.apache.hc.client5.http.auth.AuthChallenge, .AuthExchange, .AuthScheme, .AuthenticationException, .ChallengeType, .CredentialsProvider, .MalformedChallengeException, org.apache.hc.client5.http.protocol.HttpClientContext, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.http.FormattedHeader, .Header, .HttpHeaders, .HttpHost, .HttpRequest, .HttpResponse, .HttpStatus, .ParseException, org.apache.hc.core5.http.message.BasicHeader, .ParserCursor, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Asserts, .CharArrayBuffer, org.slf4j.Logger, .LoggerFactory

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

Please note that since version 5.2 this class no longer updated the authentication cache bound to the execution context.

Since
4.3

Field Summary

Modifier and TypeField and Description
private static final Logger
private final AuthChallengeParser

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addAuthResponse(final HttpHost
the hostname of the opposite endpoint.
host
,
final ChallengeType
the challenge type (target or proxy).
challengeType
,
final HttpRequest
the request message head.
request
,
final AuthExchange
the current authentication exchange state.
authExchange
,
final HttpContext
the current execution context.
context
)

Generates a response to the authentication challenge based on the actual AuthExchange state and adds it to the given HttpRequest message .

public boolean

Returns:

true if the response message represents an authentication challenge, false otherwise.
isChallenged
(final HttpHost
the hostname of the opposite endpoint.
host
,
final ChallengeType
the challenge type (target or proxy).
challengeType
,
final HttpResponse
the response message head.
response
,
final AuthExchange
the current authentication exchange state.
authExchange
,
final HttpContext
the current execution context.
context
)

Determines whether the given response represents an authentication challenge.

public boolean

Returns:

true if the authentication state has been updated, false if unchanged.
updateAuthState
(final HttpHost
the hostname of the opposite endpoint.
host
,
final ChallengeType
the challenge type (target or proxy).
challengeType
,
final HttpResponse
the response message head.
response
,
final AuthenticationStrategy
the authentication strategy.
authStrategy
,
final AuthExchange
the current authentication exchange state.
authExchange
,
final HttpContext
the current execution context.
context
)

Updates the AuthExchange state based on the challenge presented in the response message using the given AuthenticationStrategy.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
parserback to summary
private final AuthChallengeParser parser

Constructor Detail

HttpAuthenticatorback to summary
public HttpAuthenticator()

Method Detail

addAuthResponseback to summary
public void addAuthResponse(final HttpHost host, final ChallengeType challengeType, final HttpRequest request, final AuthExchange authExchange, final 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:HttpHost

the hostname of the opposite endpoint.

challengeType:ChallengeType

the challenge type (target or proxy).

request:HttpRequest

the request message head.

authExchange:AuthExchange

the current authentication exchange state.

context:HttpContext

the current execution context.

isChallengedback to summary
public boolean isChallenged(final HttpHost host, final ChallengeType challengeType, final HttpResponse response, final AuthExchange authExchange, final HttpContext context)

Determines whether the given response represents an authentication challenge.

Parameters
host:HttpHost

the hostname of the opposite endpoint.

challengeType:ChallengeType

the challenge type (target or proxy).

response:HttpResponse

the response message head.

authExchange:AuthExchange

the current authentication exchange state.

context:HttpContext

the current execution context.

Returns:boolean

true if the response message represents an authentication challenge, false otherwise.

updateAuthStateback to summary
public boolean updateAuthState(final HttpHost host, final ChallengeType challengeType, final HttpResponse response, final AuthenticationStrategy authStrategy, final AuthExchange authExchange, final HttpContext context)

Updates the AuthExchange state based on the challenge presented in the response message using the given AuthenticationStrategy.

Parameters
host:HttpHost

the hostname of the opposite endpoint.

challengeType:ChallengeType

the challenge type (target or proxy).

response:HttpResponse

the response message head.

authStrategy:AuthenticationStrategy

the authentication strategy.

authExchange:AuthExchange

the current authentication exchange state.

context:HttpContext

the current execution context.

Returns:boolean

true if the authentication state has been updated, false if unchanged.