hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1606699 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/auth/RFC2617Scheme.java test/java/org/apache/http/impl/auth/TestDigestScheme.java
Date Mon, 30 Jun 2014 11:55:47 GMT
Author: olegk
Date: Mon Jun 30 11:55:46 2014
New Revision: 1606699

URL: http://svn.apache.org/r1606699
Log:
HTTPCLIENT-1524: RFC 2617 auth schemes (basic and digest) cannot handle auth parameters with
mixed or upper case

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java?rev=1606699&r1=1606698&r2=1606699&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/RFC2617Scheme.java
Mon Jun 30 11:55:46 2014
@@ -120,7 +120,7 @@ public abstract class RFC2617Scheme exte
         }
         this.params.clear();
         for (final HeaderElement element : elements) {
-            this.params.put(element.getName(), element.getValue());
+            this.params.put(element.getName().toLowerCase(Locale.ROOT), element.getValue());
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java?rev=1606699&r1=1606698&r2=1606699&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestDigestScheme.java
Mon Jun 30 11:55:46 2014
@@ -607,6 +607,22 @@ public class TestDigestScheme {
         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)
     public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception
{
         final String challenge = "Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\",
" +



Mime
View raw message