Package org.apache.http.impl.auth
Class BasicScheme
- java.lang.Object
-
- org.apache.http.impl.auth.AuthSchemeBase
-
- org.apache.http.impl.auth.RFC2617Scheme
-
- org.apache.http.impl.auth.BasicScheme
-
- All Implemented Interfaces:
java.io.Serializable
,AuthScheme
,ContextAwareAuthScheme
public class BasicScheme extends RFC2617Scheme
Basic authentication scheme as defined in RFC 2617.- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BasicScheme()
BasicScheme(java.nio.charset.Charset credentialsCharset)
BasicScheme(ChallengeState challengeState)
Deprecated.(4.3) do not use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Header
authenticate(Credentials credentials, java.lang.String charset, boolean proxy)
Deprecated.Header
authenticate(Credentials credentials, HttpRequest request)
Header
authenticate(Credentials credentials, HttpRequest request, HttpContext context)
Produces basic authorization header for the given set ofCredentials
.java.lang.String
getSchemeName()
Returns textual designation of the basic authentication scheme.boolean
isComplete()
Tests if the Basic authentication process has been completed.boolean
isConnectionBased()
Returnsfalse
.void
processChallenge(Header header)
Processes the Basic challenge.java.lang.String
toString()
-
Methods inherited from class org.apache.http.impl.auth.RFC2617Scheme
getCredentialsCharset, getParameter, getRealm
-
Methods inherited from class org.apache.http.impl.auth.AuthSchemeBase
getChallengeState, isProxy
-
-
-
-
Constructor Detail
-
BasicScheme
public BasicScheme(java.nio.charset.Charset credentialsCharset)
- Since:
- 4.3
-
BasicScheme
@Deprecated public BasicScheme(ChallengeState challengeState)
Deprecated.(4.3) do not use.Creates an instance ofBasicScheme
with the given challenge state.- Since:
- 4.2
-
BasicScheme
public BasicScheme()
-
-
Method Detail
-
getSchemeName
public java.lang.String getSchemeName()
Returns textual designation of the basic authentication scheme.- Returns:
basic
-
processChallenge
public void processChallenge(Header header) throws MalformedChallengeException
Processes the Basic challenge.- Specified by:
processChallenge
in interfaceAuthScheme
- Overrides:
processChallenge
in classAuthSchemeBase
- Parameters:
header
- the challenge header- Throws:
MalformedChallengeException
- is thrown if the authentication challenge is malformed
-
isComplete
public boolean isComplete()
Tests if the Basic authentication process has been completed.- Returns:
true
if Basic authorization has been processed,false
otherwise.
-
isConnectionBased
public boolean isConnectionBased()
Returnsfalse
. Basic authentication scheme is request based.- Returns:
false
.
-
authenticate
@Deprecated public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException
Deprecated.Description copied from interface:AuthScheme
Produces an authorization string for the given set ofCredentials
.- Parameters:
credentials
- The set of credentials to be used for athenticationrequest
- The request being authenticated- Returns:
- the authorization string
- Throws:
AuthenticationException
- if authorization string cannot be generated due to an authentication failure
-
authenticate
public Header authenticate(Credentials credentials, HttpRequest request, HttpContext context) throws AuthenticationException
Produces basic authorization header for the given set ofCredentials
.- Specified by:
authenticate
in interfaceContextAwareAuthScheme
- Overrides:
authenticate
in classAuthSchemeBase
- Parameters:
credentials
- The set of credentials to be used for authenticationrequest
- The request being authenticatedcontext
- HTTP context- Returns:
- a basic authorization string
- Throws:
InvalidCredentialsException
- if authentication credentials are not valid or not applicable for this authentication schemeAuthenticationException
- if authorization string cannot be generated due to an authentication failure
-
authenticate
@Deprecated public static Header authenticate(Credentials credentials, java.lang.String charset, boolean proxy)
Deprecated.Returns a basicAuthorization
header value for the givenCredentials
and charset.- Parameters:
credentials
- The credentials to encode.charset
- The charset to use for encoding the credentials- Returns:
- a basic authorization header
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAuthSchemeBase
-
-