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:
java.io.Serializable
,AuthScheme
,ContextAwareAuthScheme
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.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 used by the connection.
- Since:
- 4.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DigestScheme()
DigestScheme(java.nio.charset.Charset credentialsCharset)
DigestScheme(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 Header
authenticate(Credentials credentials, HttpRequest request)
Header
authenticate(Credentials credentials, HttpRequest request, HttpContext context)
Produces a digest authorization string for the given set ofCredentials
, method name and URI.static java.lang.String
createCnonce()
Creates a random cnonce value based on the current time.java.lang.String
getSchemeName()
Returns textual designation of the digest authentication scheme.boolean
isComplete()
Tests if the Digest authentication process has been completed.boolean
isConnectionBased()
Returnsfalse
.void
overrideParamter(java.lang.String name, java.lang.String value)
void
processChallenge(Header header)
Processes the Digest 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
-
DigestScheme
public DigestScheme(java.nio.charset.Charset credentialsCharset)
- Since:
- 4.3
-
DigestScheme
@Deprecated public DigestScheme(ChallengeState challengeState)
Deprecated.(4.3) do not use.Creates an instance ofDigestScheme
with the given challenge state.- Since:
- 4.2
-
DigestScheme
public DigestScheme()
-
-
Method Detail
-
processChallenge
public void processChallenge(Header header) throws MalformedChallengeException
Processes the Digest 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 Digest authentication process has been completed.- Returns:
true
if Digest authorization has been processed,false
otherwise.
-
getSchemeName
public java.lang.String getSchemeName()
Returns textual designation of the digest authentication scheme.- Returns:
digest
-
isConnectionBased
public boolean isConnectionBased()
Returnsfalse
. Digest authentication scheme is request based.- Returns:
false
.
-
overrideParamter
public void overrideParamter(java.lang.String name, java.lang.String value)
-
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 a digest authorization string for the given set ofCredentials
, method name and URI.- Specified by:
authenticate
in interfaceContextAwareAuthScheme
- Overrides:
authenticate
in classAuthSchemeBase
- Parameters:
credentials
- A set of credentials to be used for athenticationrequest
- The request being authenticatedcontext
- HTTP context- 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
public static java.lang.String createCnonce()
Creates a random cnonce value based on the current time.- Returns:
- The cnonce value as String.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAuthSchemeBase
-
-