@AuthStateCacheable public class BasicScheme extends Object implements AuthScheme, StateHolder<BasicScheme.State>, Serializable
Modifier and Type | Class and Description |
---|---|
static class |
BasicScheme.State |
Constructor and Description |
---|
BasicScheme()
Constructs a new BasicScheme with UTF-8 as the charset.
|
BasicScheme(Charset charset)
Deprecated.
This constructor is deprecated to enforce the use of
StandardCharsets.UTF_8 encoding
in compliance with RFC 7617 for HTTP Basic Authentication. Use the default constructor BasicScheme() instead. |
Modifier and Type | Method and Description |
---|---|
String |
generateAuthResponse(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.
|
String |
getName()
Returns textual designation of the given authentication scheme.
|
Principal |
getPrincipal()
Returns
Principal whose credentials are used to generate
an authentication response. |
String |
getRealm()
Returns authentication realm.
|
void |
initPreemptive(Credentials credentials) |
boolean |
isChallengeComplete()
Authentication process may involve a series of challenge-response exchanges.
|
boolean |
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
|
boolean |
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.
|
void |
restore(BasicScheme.State state) |
BasicScheme.State |
store() |
String |
toString() |
@Deprecated public BasicScheme(Charset charset)
StandardCharsets.UTF_8
encoding
in compliance with RFC 7617 for HTTP Basic Authentication. Use the default constructor BasicScheme()
instead.charset
- the Charset
set to be used for encoding credentials. This parameter is ignored as UTF-8 is always used.public BasicScheme()
public void initPreemptive(Credentials credentials)
public String getName()
AuthScheme
getName
in interface AuthScheme
public boolean isConnectionBased()
AuthScheme
isConnectionBased
in interface AuthScheme
true
if the scheme is connection based, false
if the scheme is request based.public String getRealm()
AuthScheme
null
.getRealm
in interface AuthScheme
public void processChallenge(AuthChallenge authChallenge, org.apache.hc.core5.http.protocol.HttpContext context) throws MalformedChallengeException
AuthScheme
processChallenge
in interface AuthScheme
authChallenge
- the auth challengecontext
- HTTP contextMalformedChallengeException
- in case the auth challenge is incomplete,
malformed or otherwise invalid.public boolean isChallengeComplete()
AuthScheme
isChallengeComplete
in interface AuthScheme
true
if the authentication process has been completed,
false
otherwise.public boolean isResponseReady(org.apache.hc.core5.http.HttpHost host, CredentialsProvider credentialsProvider, org.apache.hc.core5.http.protocol.HttpContext context) throws AuthenticationException
AuthScheme
isResponseReady
in interface AuthScheme
credentialsProvider
- The credentials to be used for authenticationcontext
- HTTP contexttrue
if an authorization response can be generated and
the authentication handshake can proceed, false
otherwise.AuthenticationException
- if authorization string cannot
be generated due to an authentication failurepublic Principal getPrincipal()
AuthScheme
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.getPrincipal
in interface AuthScheme
AuthScheme.isConnectionBased()
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
AuthScheme
CredentialsProvider
prior to this method call.generateAuthResponse
in interface AuthScheme
request
- The request being authenticatedcontext
- HTTP contextAuthenticationException
- if authorization string cannot
be generated due to an authentication failureAuthScheme.isResponseReady(HttpHost, CredentialsProvider, HttpContext)
public BasicScheme.State store()
store
in interface StateHolder<BasicScheme.State>
public void restore(BasicScheme.State state)
restore
in interface StateHolder<BasicScheme.State>
Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.