hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1654753 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/impl/auth/ test/java/org/apache/http/impl/auth/
Date Mon, 26 Jan 2015 10:03:13 GMT
Author: olegk
Date: Mon Jan 26 10:03:12 2015
New Revision: 1654753

URL: http://svn.apache.org/r1654753
Log:
HTTPCLIENT-1604: accept empty BASIC auth challenge as valid

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
    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/TestBasicScheme.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java?rev=1654753&r1=1654752&r2=1654753&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
Mon Jan 26 10:03:12 2015
@@ -140,6 +140,9 @@ public class DigestScheme extends RFC261
             final Header header) throws MalformedChallengeException {
         super.processChallenge(header);
         this.complete = true;
+        if (getParameters().isEmpty()) {
+            throw new MalformedChallengeException("Authentication challenge is empty");
+        }
     }
 
     /**

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=1654753&r1=1654752&r2=1654753&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 Jan 26 10:03:12 2015
@@ -115,9 +115,6 @@ public abstract class RFC2617Scheme exte
         final HeaderValueParser parser = BasicHeaderValueParser.INSTANCE;
         final ParserCursor cursor = new ParserCursor(pos, buffer.length());
         final HeaderElement[] elements = parser.parseElements(buffer, cursor);
-        if (elements.length == 0) {
-            throw new MalformedChallengeException("Authentication challenge is empty");
-        }
         this.params.clear();
         for (final HeaderElement element : elements) {
             this.params.put(element.getName().toLowerCase(Locale.ROOT), element.getValue());

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java?rev=1654753&r1=1654752&r2=1654753&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestBasicScheme.java
Mon Jan 26 10:03:12 2015
@@ -37,7 +37,6 @@ import org.apache.http.Header;
 import org.apache.http.HttpRequest;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.MalformedChallengeException;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.message.BasicHeader;
 import org.apache.http.message.BasicHttpRequest;
@@ -52,12 +51,13 @@ import org.junit.Test;
  */
 public class TestBasicScheme {
 
-    @Test(expected=MalformedChallengeException.class)
-    public void testBasicAuthenticationWithNoRealm() throws Exception {
+    @Test
+    public void testBasicAuthenticationEmptyChallenge() throws Exception {
         final String challenge = "Basic";
         final Header header = new BasicHeader(AUTH.WWW_AUTH, challenge);
         final AuthScheme authscheme = new BasicScheme();
         authscheme.processChallenge(header);
+        Assert.assertNull(authscheme.getRealm());
     }
 
     @Test

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java?rev=1654753&r1=1654752&r2=1654753&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestRFC2617Scheme.java
Mon Jan 26 10:03:12 2015
@@ -143,13 +143,6 @@ public class TestRFC2617Scheme {
     }
 
     @Test(expected=MalformedChallengeException.class)
-    public void testEmptyHeader() throws Exception {
-        final TestAuthScheme authscheme = new TestAuthScheme();
-        final Header header = new BasicHeader(AUTH.WWW_AUTH, "Test    ");
-        authscheme.processChallenge(header);
-    }
-
-    @Test(expected=MalformedChallengeException.class)
     public void testInvalidHeaderValue() throws Exception {
         final TestAuthScheme authscheme = new TestAuthScheme();
         final Header header = new BasicHeader("whatever", "whatever");



Mime
View raw message