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

public Class BasicScheme

extends Object
implements AuthScheme, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.hc.client5.http.auth.AuthScheme
Annotations
@AuthStateCacheable
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.nio.charset.Charset, .StandardCharsets, .UnsupportedCharsetException, java.security.Principal, java.util.HashMap, .List, .Locale, .Map, org.apache.hc.client5.http.auth.AuthChallenge, .AuthScheme, .AuthScope, .AuthStateCacheable, .AuthenticationException, .Credentials, .CredentialsProvider, .MalformedChallengeException, .StandardAuthScheme, .UsernamePasswordCredentials, org.apache.hc.client5.http.protocol.HttpClientContext, org.apache.hc.client5.http.utils.Base64, .ByteArrayBuilder, org.apache.hc.core5.http.HttpHost, .HttpRequest, .NameValuePair, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Args, org.slf4j.Logger, .LoggerFactory

Basic authentication scheme.
Since
4.0

Field Summary

Modifier and TypeField and Description
private transient Base64
private transient ByteArrayBuilder
private boolean
private UsernamePasswordCredentials
private transient Charset
private static final Logger
private final Map<String, String>
private static final long

Constructor Summary

AccessConstructor and Description
public
BasicScheme(final Charset charset)

public

Method Summary

Modifier and TypeMethod and Description
public String
generateAuthResponse(final HttpHost host, final HttpRequest
The request being authenticated
request
,
final HttpContext
HTTP context
context
)

Implements org.apache.hc.client5.http.auth.AuthScheme.generateAuthResponse.

Generates an authorization response based on the current state.
public String
getName()

Implements org.apache.hc.client5.http.auth.AuthScheme.getName.

Returns textual designation of the given authentication scheme.
public Principal
getPrincipal()

Implements org.apache.hc.client5.http.auth.AuthScheme.getPrincipal.

Returns Principal whose credentials are used to generate an authentication response.
public String
getRealm()

Implements org.apache.hc.client5.http.auth.AuthScheme.getRealm.

Returns authentication realm.
public void
initPreemptive(final Credentials credentials)

public boolean
isChallengeComplete()

Implements org.apache.hc.client5.http.auth.AuthScheme.isChallengeComplete.

Authentication process may involve a series of challenge-response exchanges.
public boolean
isConnectionBased()

Implements org.apache.hc.client5.http.auth.AuthScheme.isConnectionBased.

Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basis
public boolean
isResponseReady(final HttpHost host, final CredentialsProvider
The credentials to be used for authentication
credentialsProvider
,
final HttpContext
HTTP context
context
)

Implements org.apache.hc.client5.http.auth.AuthScheme.isResponseReady.

Determines whether or not an authorization response can be generated based on the actual authentication state.
public void
processChallenge(final AuthChallenge
the auth challenge
authChallenge
,
final HttpContext
HTTP context
context
)

Implements org.apache.hc.client5.http.auth.AuthScheme.processChallenge.

Processes the given auth challenge.
private void
private void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

base64codecback to summary
private transient Base64 base64codec
bufferback to summary
private transient ByteArrayBuilder buffer
completeback to summary
private boolean complete
credentialsback to summary
private UsernamePasswordCredentials credentials
defaultCharsetback to summary
private transient Charset defaultCharset
LOGback to summary
private static final Logger LOG
paramMapback to summary
private final Map<String, String> paramMap
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

BasicSchemeback to summary
public BasicScheme(final Charset charset)
Since
4.3
BasicSchemeback to summary
public BasicScheme()

Method Detail

generateAuthResponseback to summary
public String generateAuthResponse(final HttpHost host, final HttpRequest request, final HttpContext context) throws AuthenticationException

Implements org.apache.hc.client5.http.auth.AuthScheme.generateAuthResponse.

Doc from org.apache.hc.client5.http.auth.AuthScheme.generateAuthResponse.

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 a CredentialsProvider prior to this method call.

Parameters
request:HttpRequest

The request being authenticated

context:HttpContext

HTTP context

Returns:String

authorization header

Annotations
@Override
Exceptions
AuthenticationException:
if authorization string cannot be generated due to an authentication failure
getNameback to summary
public String getName()

Implements org.apache.hc.client5.http.auth.AuthScheme.getName.

Doc from org.apache.hc.client5.http.auth.AuthScheme.getName.

Returns textual designation of the given authentication scheme.

Returns:String

the name of the given authentication scheme

Annotations
@Override
getPrincipalback to summary
public Principal getPrincipal()

Implements org.apache.hc.client5.http.auth.AuthScheme.getPrincipal.

Doc from org.apache.hc.client5.http.auth.AuthScheme.getPrincipal.

Returns Principal whose credentials are used to generate an authentication response. Connection based schemes are required to return a user Principal if authorization applies to for the entire life span of connection.

Returns:Principal

user principal

Annotations
@Override
getRealmback to summary
public String getRealm()

Implements org.apache.hc.client5.http.auth.AuthScheme.getRealm.

Doc from org.apache.hc.client5.http.auth.AuthScheme.getRealm.

Returns authentication realm. If the concept of an authentication realm is not applicable to the given authentication scheme, returns null.

Returns:String

the authentication realm

Annotations
@Override
initPreemptiveback to summary
public void initPreemptive(final Credentials credentials)
isChallengeCompleteback to summary
public boolean isChallengeComplete()

Implements org.apache.hc.client5.http.auth.AuthScheme.isChallengeComplete.

Doc from org.apache.hc.client5.http.auth.AuthScheme.isChallengeComplete.

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.

Returns:boolean

true if the authentication process has been completed, false otherwise.

Annotations
@Override
isConnectionBasedback to summary
public boolean isConnectionBased()

Implements org.apache.hc.client5.http.auth.AuthScheme.isConnectionBased.

Doc from org.apache.hc.client5.http.auth.AuthScheme.isConnectionBased.

Determines if the authentication scheme is expected to provide an authorization response on a per connection basis instead of the standard per request basis

Returns:boolean

true if the scheme is connection based, false if the scheme is request based.

Annotations
@Override
isResponseReadyback to summary
public boolean isResponseReady(final HttpHost host, final CredentialsProvider credentialsProvider, final HttpContext context) throws AuthenticationException

Implements org.apache.hc.client5.http.auth.AuthScheme.isResponseReady.

Doc from org.apache.hc.client5.http.auth.AuthScheme.isResponseReady.

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.

Parameters
credentialsProvider:CredentialsProvider

The credentials to be used for authentication

context:HttpContext

HTTP context

Returns:boolean

true if an authorization response can be generated and the authentication handshake can proceed, false otherwise.

Annotations
@Override
Exceptions
AuthenticationException:
if authorization string cannot be generated due to an authentication failure
processChallengeback to summary
public void processChallenge(final AuthChallenge authChallenge, final HttpContext context) throws MalformedChallengeException

Implements org.apache.hc.client5.http.auth.AuthScheme.processChallenge.

Doc from org.apache.hc.client5.http.auth.AuthScheme.processChallenge.

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

Parameters
authChallenge:AuthChallenge

the auth challenge

context:HttpContext

HTTP context

Annotations
@Override
Exceptions
MalformedChallengeException:
in case the auth challenge is incomplete, malformed or otherwise invalid.
readObjectback to summary
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException
Annotations
@SuppressWarnings:unchecked
readObjectNoDataback to summary
private void readObjectNoData()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
validateUsernameback to summary
private void validateUsername() throws AuthenticationException
writeObjectback to summary
private void writeObject(final ObjectOutputStream out) throws IOException