org.apache.commons.httpclient.auth
Class DigestScheme
java.lang.Object
|
+--org.apache.commons.httpclient.auth.AuthSchemeBase
|
+--org.apache.commons.httpclient.auth.RFC2617Scheme
|
+--org.apache.commons.httpclient.auth.DigestScheme
- public class DigestScheme
- extends RFC2617Scheme
Digest authentication scheme as defined in RFC 2617.
- Author:
- Remy Maucherat, Rodney Waldhoff, Jeff Dever, Ortwin Gl?ck, Sean C. Sullivan, Adrian Sutton, Mike Bowler, Oleg Kalnichevski
Constructor Summary |
DigestScheme(String challenge)
Constructor for the digest authentication scheme. |
DigestScheme
public DigestScheme(String challenge)
throws MalformedChallengeException
- Constructor for the digest authentication scheme.
- Parameters:
challenge
- The authentication challenge- Throws:
- MalformedChallengeException - is thrown if the authentication challenge
is malformed
getSchemeName
public String getSchemeName()
- Returns textual designation of the digest authentication scheme.
- Returns:
digest
authenticate
public String authenticate(Credentials credentials,
String method,
String uri)
throws AuthenticationException
- 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 athenticationmethod
- the name of the method that requires authorization.uri
- The URI for which authorization is needed.- Returns:
- a digest authorization string
- Throws:
- AuthenticationException - if authorization string cannot
be generated due to an authentication failure
- See Also:
HttpMethod.getName()
,
HttpMethod.getPath()
authenticate
public static String authenticate(UsernamePasswordCredentials credentials,
Map params)
throws AuthenticationException
- Produces a digest authorization string for the given set of
UsernamePasswordCredentials
and authetication parameters.
- Parameters:
credentials
- Credentials to create the digest withparams
- The authetication parameters. The following
parameters are expected: uri
, realm
,
nonce
, nc
, cnonce
,
qop
, methodname
.- Returns:
- a digest authorization string
- Throws:
- AuthenticationException - if authorization string cannot
be generated due to an authentication failure
createDigest
public static String createDigest(String uname,
String pwd,
Map params)
throws AuthenticationException
- Creates an MD5 response digest.
- Parameters:
uname
- Usernamepwd
- Passwordparams
- The parameters necessary to construct the digest.
The following parameters are expected: uri
,
realm
, nonce
, nc
,
cnonce
, qop
, methodname
.- Returns:
- The created digest as string. This will be the response tag's
value in the Authentication HTTP header.
- Throws:
- AuthenticationException - when MD5 is an unsupported algorithm
createDigestHeader
public static String createDigestHeader(String uname,
Map params,
String digest)
- Creates digest-response header as defined in RFC2617.
- Parameters:
uname
- Usernameparams
- The parameters necessary to construct the digest header.
The following parameters are expected: uri
,
realm
, nonce
, nc
,
cnonce
, qop
, methodname
.digest
- The response tag's value as String.- Returns:
- The digest-response as String.
createCnonce
public static String createCnonce()
throws AuthenticationException
- Creates a random cnonce value based on the current time.
- Returns:
- The cnonce value as String.
- Throws:
- AuthenticationException - if MD5 algorithm is not supported.
Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.