commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r161944 - in jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/auth/AuthState.java test/org/apache/commons/httpclient/TestNoHost.java test/org/apache/commons/httpclient/TestProxy.java
Date Tue, 19 Apr 2005 18:33:03 GMT
Author: olegk
Date: Tue Apr 19 11:33:02 2005
New Revision: 161944

URL: http://svn.apache.org/viewcvs?view=rev&rev=161944
Log:
PR #34427 (IllegalStateException: Authentication state already initialized)

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Gl├╝ck & Michael Becke 

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthState.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoHost.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthState.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthState.java?view=diff&r1=161943&r2=161944
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthState.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/auth/AuthState.java
Tue Apr 19 11:33:02 2005
@@ -112,11 +112,13 @@
      * Preemptively assigns Basic authentication scheme.
      */
     public void setPreemptive() {
-        if (this.authScheme != null) {
-            throw new IllegalStateException("Authentication state already initialized");
+        if (!this.preemptive) {
+            if (this.authScheme != null) {
+                throw new IllegalStateException("Authentication state already initialized");
+            }
+            this.authScheme = AuthPolicy.getAuthScheme("basic");
+            this.preemptive = true;
         }
-        this.authScheme = AuthPolicy.getAuthScheme("basic");
-        this.preemptive = true;
     }
 
     /**

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoHost.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoHost.java?view=diff&r1=161943&r2=161944
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoHost.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestNoHost.java
Tue Apr 19 11:33:02 2005
@@ -103,6 +103,7 @@
         suite.addTest(TestNoncompliant.suite());
         // Proxy
         suite.addTest(TestProxy.suite());
+        suite.addTest(TestProxyWithRedirect.suite());
         return suite;
     }
 

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java?view=diff&r1=161943&r2=161944
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestProxy.java
Tue Apr 19 11:33:02 2005
@@ -753,4 +753,23 @@
         }
     }
 
+    public void testPreemptiveAuthProxy() throws Exception {
+        UsernamePasswordCredentials creds = 
+            new UsernamePasswordCredentials("testuser", "testpass");
+        
+        this.client.getState().setProxyCredentials(AuthScope.ANY, creds);
+        this.client.getParams().setAuthenticationPreemptive(true);
+        this.server.setHttpService(new FeedbackService());
+
+        this.proxy.requireAuthentication(creds, "test", true);
+        
+        GetMethod get = new GetMethod("/");
+        try {
+            this.client.executeMethod(get);
+            assertEquals(HttpStatus.SC_OK, get.getStatusCode());
+        } finally {
+            get.releaseConnection();
+        }
+    }
+        
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message