HTTPCLIENT-1524: RFC 2617 auth schemes (basic and digest) cannot handle auth parameters with mixed or upper case

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1606699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-06-30 11:55:46 +00:00
parent dbf7a77171
commit 8ed2196cd7
2 changed files with 17 additions and 1 deletions

View File

@ -120,7 +120,7 @@ public abstract class RFC2617Scheme extends AuthSchemeBase implements Serializab
} }
this.params.clear(); this.params.clear();
for (final HeaderElement element : elements) { for (final HeaderElement element : elements) {
this.params.put(element.getName(), element.getValue()); this.params.put(element.getName().toLowerCase(Locale.ROOT), element.getValue());
} }
} }

View File

@ -607,6 +607,22 @@ public class TestDigestScheme {
Assert.assertEquals("f2a3f18799759d4f1a1c068b92b573cb", table.get("nonce")); Assert.assertEquals("f2a3f18799759d4f1a1c068b92b573cb", table.get("nonce"));
} }
@Test
public void testParameterCaseSensitivity() throws Exception {
final String challenge = "Digest Realm=\"-\", " +
"nonce=\"YjYuNGYyYmJhMzUuY2I5ZDhlZDE5M2ZlZDM 1Mjk3NGJkNTIyYjgyNTcwMjQ=\", " +
"opaque=\"98700A3D9CE17065E2246B41035C6609\", qop=\"auth\"";
final Header authChallenge = new BasicHeader(AUTH.PROXY_AUTH, challenge);
final HttpRequest request = new BasicHttpRequest("GET", "/");
final Credentials cred = new UsernamePasswordCredentials("username","password");
final DigestScheme authscheme = new DigestScheme();
final HttpContext context = new BasicHttpContext();
authscheme.processChallenge(authChallenge);
Assert.assertEquals("-", authscheme.getRealm());
authscheme.authenticate(cred, request, context);
}
@Test(expected=AuthenticationException.class) @Test(expected=AuthenticationException.class)
public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception { public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception {
final String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", " + final String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", " +