Class BasicScheme
java.lang.Object
org.apache.hc.client5.http.impl.auth.BasicScheme
- All Implemented Interfaces:
Serializable
,AuthScheme
Basic authentication scheme.
- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Base64
private ByteArrayBuilder
private boolean
private UsernamePasswordCredentials
private Charset
private static final org.slf4j.Logger
private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateAuthResponse
(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context) Generates an authorization response based on the current state.getName()
Returns textual designation of the given authentication scheme.ReturnsPrincipal
whose credentials are used to generate an authentication response.getRealm()
Returns authentication realm.void
initPreemptive
(Credentials credentials) boolean
Authentication process may involve a series of challenge-response exchanges.boolean
Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basisboolean
isResponseReady
(org.apache.hc.core5.http.HttpHost host, CredentialsProvider credentialsProvider, org.apache.hc.core5.http.protocol.HttpContext context) Determines whether or not an authorization response can be generated based on the actual authentication state.void
processChallenge
(AuthChallenge authChallenge, org.apache.hc.core5.http.protocol.HttpContext context) Processes the given auth challenge.private void
private void
toString()
private void
private void
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
LOG
private static final org.slf4j.Logger LOG -
paramMap
-
defaultCharset
-
buffer
-
base64codec
-
complete
private boolean complete -
credentials
-
-
Constructor Details
-
BasicScheme
- Since:
- 4.3
-
BasicScheme
public BasicScheme()
-
-
Method Details
-
initPreemptive
-
getName
Description copied from interface:AuthScheme
Returns textual designation of the given authentication scheme.- Specified by:
getName
in interfaceAuthScheme
- Returns:
- the name of the given authentication scheme
-
isConnectionBased
public boolean isConnectionBased()Description copied from interface:AuthScheme
Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basis- Specified by:
isConnectionBased
in interfaceAuthScheme
- Returns:
true
if the scheme is connection based,false
if the scheme is request based.
-
getRealm
Description copied from interface:AuthScheme
Returns authentication realm. If the concept of an authentication realm is not applicable to the given authentication scheme, returnsnull
.- Specified by:
getRealm
in interfaceAuthScheme
- Returns:
- the authentication realm
-
processChallenge
public void processChallenge(AuthChallenge authChallenge, org.apache.hc.core5.http.protocol.HttpContext context) throws MalformedChallengeException Description copied from interface:AuthScheme
Processes the given auth challenge. Some authentication schemes may involve multiple challenge-response exchanges. Such schemes must be able to maintain internal state when dealing with sequential challenges- Specified by:
processChallenge
in interfaceAuthScheme
- Parameters:
authChallenge
- the auth challengecontext
- HTTP context- Throws:
MalformedChallengeException
- in case the auth challenge is incomplete, malformed or otherwise invalid.
-
isChallengeComplete
public boolean isChallengeComplete()Description copied from interface:AuthScheme
Authentication process may involve a series of challenge-response exchanges. This method tests if the authorization process has been fully completed (either successfully or unsuccessfully), that is, all the required authorization challenges have been processed in their entirety.- Specified by:
isChallengeComplete
in interfaceAuthScheme
- Returns:
true
if the authentication process has been completed,false
otherwise.
-
isResponseReady
public boolean isResponseReady(org.apache.hc.core5.http.HttpHost host, CredentialsProvider credentialsProvider, org.apache.hc.core5.http.protocol.HttpContext context) throws AuthenticationException Description copied from interface:AuthScheme
Determines whether or not an authorization response can be generated based on the actual authentication state. Generally the outcome of this method will depend upon availability of user credentials necessary to produce an authorization response.- Specified by:
isResponseReady
in interfaceAuthScheme
- Parameters:
credentialsProvider
- The credentials to be used for authenticationcontext
- HTTP context- Returns:
true
if an authorization response can be generated and the authentication handshake can proceed,false
otherwise.- Throws:
AuthenticationException
- if authorization string cannot be generated due to an authentication failure
-
getPrincipal
Description copied from interface:AuthScheme
ReturnsPrincipal
whose credentials are used to generate an authentication response. Connection based schemes are required to return a userPrincipal
if authorization applies to for the entire life span of connection.- Specified by:
getPrincipal
in interfaceAuthScheme
- Returns:
- user principal
- See Also:
-
validateUsername
- Throws:
AuthenticationException
-
generateAuthResponse
public String generateAuthResponse(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context) throws AuthenticationException Description copied from interface:AuthScheme
Generates an authorization response based on the current state. Some authentication schemes may need to load user credentials required to generate an authorization response from aCredentialsProvider
prior to this method call.- Specified by:
generateAuthResponse
in interfaceAuthScheme
- Parameters:
request
- The request being authenticatedcontext
- HTTP context- Returns:
- authorization header
- Throws:
AuthenticationException
- if authorization string cannot be generated due to an authentication failure- See Also:
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
IOException
ClassNotFoundException
-
readObjectNoData
private void readObjectNoData() -
toString
-