Package org.apache.http.impl.auth
Class DigestScheme
java.lang.Object
org.apache.http.impl.auth.AuthSchemeBase
org.apache.http.impl.auth.RFC2617Scheme
org.apache.http.impl.auth.DigestScheme
- All Implemented Interfaces:
AuthScheme
public class DigestScheme extends RFC2617Scheme
Digest authentication scheme as defined in RFC 2617. Both MD5 (default) and MD5-sess are supported. Currently only qop=auth or no qop is supported. qop=auth-int is unsupported. If auth and auth-int are provided, auth is used.
Credential charset is configured via the
credential charset parameter.
Since the digest username is included as clear text in the generated
Authentication header, the charset of the username must be compatible
with the
http element charset.
- 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 DigestScheme()Default constructor for the digest authetication scheme. -
Method Summary
Modifier and Type Method Description Headerauthenticate(Credentials credentials, HttpRequest request)Produces a digest authorization string for the given set ofCredentials, method name and URI.static StringcreateCnonce()Creates a random cnonce value based on the current time.StringgetSchemeName()Returns textual designation of the digest authentication scheme.booleanisComplete()Tests if the Digest authentication process has been completed.booleanisConnectionBased()Returns false.voidoverrideParamter(String name, String value)voidprocessChallenge(Header header)Processes the Digest 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
-
DigestScheme
public DigestScheme()Default constructor for the digest authetication scheme.
-
-
Method Details
-
processChallenge
Processes the Digest 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 Digest authentication process has been completed.- Returns:
- true if Digest authorization has been processed, false otherwise.
-
getSchemeName
Returns textual designation of the digest authentication scheme.- Returns:
digest
-
isConnectionBased
public boolean isConnectionBased()Returns false. Digest authentication scheme is request based.- Returns:
- false.
-
overrideParamter
-
authenticate
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationExceptionProduces a digest authorization string for the given set ofCredentials, method name and URI.- Parameters:
credentials- A set of credentials to be used for athenticationrequest- The request being authenticated- Returns:
- a digest 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
-
createCnonce
Creates a random cnonce value based on the current time.- Returns:
- The cnonce value as String.
- Throws:
UnsupportedDigestAlgorithmException- if MD5 algorithm is not supported.
-