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:
AuthScheme
public class BasicScheme extends RFC2617Scheme
Basic authentication scheme as defined in RFC 2617.
- Since:
- 4.0
- Author:
- Remy Maucherat, Rodney Waldhoff, Jeff Dever, Ortwin Glueck, Sean C. Sullivan, Adrian Sutton, Mike Bowler, Oleg Kalnichevski
-
Constructor Summary
Constructors Constructor Description BasicScheme()Default constructor for the basic authetication scheme. -
Method Summary
Modifier and Type Method Description static Headerauthenticate(Credentials credentials, String charset, boolean proxy)Returns a basic Authorization header value for the givenCredentialsand charset.Headerauthenticate(Credentials credentials, HttpRequest request)Produces basic authorization header for the given set ofCredentials.StringgetSchemeName()Returns textual designation of the basic authentication scheme.booleanisComplete()Tests if the Basic authentication process has been completed.booleanisConnectionBased()Returns false.voidprocessChallenge(Header header)Processes the Basic challenge.Methods inherited from class org.apache.http.impl.auth.RFC2617Scheme
getParameter, getParameters, getRealm, parseChallengeMethods inherited from class org.apache.http.impl.auth.AuthSchemeBase
isProxy
-
Constructor Details
-
BasicScheme
public BasicScheme()Default constructor for the basic authetication scheme.
-
-
Method Details
-
getSchemeName
Returns textual designation of the basic authentication scheme.- Returns:
basic
-
processChallenge
Processes the Basic challenge.- Specified by:
processChallengein interfaceAuthScheme- Overrides:
processChallengein 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()Returns false. Basic authentication scheme is request based.- Returns:
- false.
-
authenticate
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationExceptionProduces basic authorization header for the given set ofCredentials.- Parameters:
credentials- The set of credentials to be used for athenticationrequest- The request being authenticated- 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
Returns a basic Authorization header value for the givenCredentialsand charset.- Parameters:
credentials- The credentials to encode.charset- The charset to use for encoding the credentials- Returns:
- a basic authorization header
-