Index: src/java/org/apache/commons/httpclient/auth/DigestScheme.java =================================================================== --- src/java/org/apache/commons/httpclient/auth/DigestScheme.java (revision 171105) +++ src/java/org/apache/commons/httpclient/auth/DigestScheme.java (working copy) @@ -138,8 +138,8 @@ */ public DigestScheme(final String challenge) throws MalformedChallengeException { - super(challenge); - this.complete = true; + super(); + processChallenge(challenge); } /** @@ -260,13 +260,11 @@ "Credentials cannot be used for digest authentication: " + credentials.getClass().getName()); } - this.getParameters().put("methodname", method); - this.getParameters().put("uri", uri); + getParameters().put("methodname", method); + getParameters().put("uri", uri); String digest = createDigest( usernamepassword.getUserName(), - usernamepassword.getPassword(), - "ISO-8859-1"); - + usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest); } @@ -299,13 +297,15 @@ "Credentials cannot be used for digest authentication: " + credentials.getClass().getName()); } - this.getParameters().put("methodname", method.getName()); - this.getParameters().put("uri", method.getPath()); + getParameters().put("methodname", method.getName()); + getParameters().put("uri", method.getPath()); + String charset = getParameter("charset"); + if (charset == null) { + getParameters().put("charset", method.getParams().getCredentialCharset()); + } String digest = createDigest( usernamepassword.getUserName(), - usernamepassword.getPassword(), - method.getParams().getCredentialCharset()); - + usernamepassword.getPassword()); return "Digest " + createDigestHeader(usernamepassword.getUserName(), digest); } @@ -321,7 +321,7 @@ * value in the Authentication HTTP header. * @throws AuthenticationException when MD5 is an unsupported algorithm */ - private String createDigest(String uname, String pwd, String charset) throws AuthenticationException { + private String createDigest(final String uname, final String pwd) throws AuthenticationException { LOG.trace("enter DigestScheme.createDigest(String, String, Map)"); @@ -334,11 +334,15 @@ String qop = getParameter("qop"); String method = getParameter("methodname"); String algorithm = getParameter("algorithm"); - // If an algorithm is not specified, default to MD5. - if(algorithm == null) { - algorithm="MD5"; + if (algorithm == null) { + algorithm = "MD5"; } + // If an charset is not specified, default to ISO-8859-1. + String charset = getParameter("charset"); + if (charset == null) { + charset = "ISO-8859-1"; + } if (qopVariant == QOP_AUTH_INT) { LOG.warn("qop=auth-int is not supported");