public class

DigestScheme

extends RFC2617Scheme
java.lang.Object
   ↳ org.apache.http.impl.auth.AuthSchemeBase
     ↳ org.apache.http.impl.auth.RFC2617Scheme
       ↳ org.apache.http.impl.auth.DigestScheme

Class Overview

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 of the HTTP request.

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.

The following parameters can be used to customize the behavior of this class:

Summary

Public Constructors
DigestScheme()
Default constructor for the digest authetication scheme.
Public Methods
Header authenticate(Credentials credentials, HttpRequest request)
Produces a digest authorization string for the given set of Credentials, method name and URI.
static String createCnonce()
Creates a random cnonce value based on the current time.
String getSchemeName()
Returns textual designation of the digest authentication scheme.
boolean isComplete()
Tests if the Digest authentication process has been completed.
boolean isConnectionBased()
Returns false.
void overrideParamter(String name, String value)
void processChallenge(Header header)
Processes the Digest challenge.
[Expand]
Inherited Methods
From class org.apache.http.impl.auth.RFC2617Scheme
From class org.apache.http.impl.auth.AuthSchemeBase
From class java.lang.Object
From interface org.apache.http.auth.AuthScheme
From interface org.apache.http.auth.ContextAwareAuthScheme

Public Constructors

public DigestScheme ()

Also: HttpClient

Default constructor for the digest authetication scheme.

Public Methods

public Header authenticate (Credentials credentials, HttpRequest request)

Also: HttpClient

Produces a digest authorization string for the given set of Credentials, method name and URI.

Parameters
credentials A set of credentials to be used for athentication
request The request being authenticated
Returns
  • a digest authorization string
Throws
InvalidCredentialsException if authentication credentials are not valid or not applicable for this authentication scheme
AuthenticationException if authorization string cannot be generated due to an authentication failure

public static String createCnonce ()

Also: HttpClient

Creates a random cnonce value based on the current time.

Returns
  • The cnonce value as String.
Throws
UnsupportedDigestAlgorithmException if MD5 algorithm is not supported.

public String getSchemeName ()

Also: HttpClient

Returns textual designation of the digest authentication scheme.

Returns
  • digest

public boolean isComplete ()

Also: HttpClient

Tests if the Digest authentication process has been completed.

Returns
  • true if Digest authorization has been processed, false otherwise.

public boolean isConnectionBased ()

Also: HttpClient

Returns false. Digest authentication scheme is request based.

Returns
  • false.

public void overrideParamter (String name, String value)

Also: HttpClient

public void processChallenge (Header header)

Also: HttpClient

Processes the Digest challenge.

Parameters
header the challenge header
Throws
MalformedChallengeException is thrown if the authentication challenge is malformed