hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1182317 - in /httpcomponents/httpclient/trunk/httpclient/src: main/java/org/apache/http/auth/ main/java/org/apache/http/client/protocol/ main/java/org/apache/http/impl/client/ test/java/org/apache/http/client/protocol/ test/java/org/apache...
Date Wed, 12 Oct 2011 11:45:55 GMT
Author: olegk
Date: Wed Oct 12 11:45:54 2011
New Revision: 1182317

URL: http://svn.apache.org/viewvc?rev=1182317&view=rev
Log:
Updated AuthState API

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthenticationBase.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpAuthenticator.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthenticationBase.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestProxyAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestTargetAuthentication.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java
    httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestHttpAuthenticator.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
Wed Oct 12 11:45:54 2011
@@ -30,7 +30,6 @@ import java.util.Queue;
 
 import org.apache.http.annotation.NotThreadSafe;
 
-
 /**
  * This class provides detailed information about the state of the authentication process.
  *
@@ -51,6 +50,7 @@ public class AuthState {
     /** Credentials selected for authentication */
     private Credentials credentials;
 
+    /** Available auth options */
     private Queue<AuthOption> authOptions;
 
     public AuthState() {
@@ -59,7 +59,9 @@ public class AuthState {
     }
 
     /**
-     * Resets authentication state.
+     * Resets the auth state.
+     *
+     * @since 4.2
      */
     public void reset() {
         this.state = AuthProtocolState.UNCHALLENGED;
@@ -70,70 +72,127 @@ public class AuthState {
     }
 
     /**
-     * Invalidates the authentication state by resetting its parameters.
-     *
-     * @deprecated use {@link #reset()}
+     * @since 4.2
      */
-    @Deprecated
-    public void invalidate() {
-        reset();
+    public AuthProtocolState getState() {
+        return this.state;
     }
 
-    @Deprecated
-    public boolean isValid() {
-        return this.authScheme != null;
+    /**
+     * @since 4.2
+     */
+    public void setState(final AuthProtocolState state) {
+        this.state = state != null ? state : AuthProtocolState.UNCHALLENGED;
     }
 
     /**
-     * Assigns the given {@link AuthScheme authentication scheme}.
+     * Returns actual {@link AuthScheme}. May be null.
+     */
+    public AuthScheme getAuthScheme() {
+        return this.authScheme;
+    }
+
+    /**
+     * Returns actual {@link Credentials}. May be null.
+     */
+    public Credentials getCredentials() {
+        return this.credentials;
+    }
+
+    /**
+     * Updates the auth state with {@link AuthScheme} and {@link Credentials}.
      *
-     * @param authScheme the {@link AuthScheme authentication scheme}
+     * @param authScheme auth scheme. May not be null.
+     * @param credentials user crednetials. May not be null.
+     *
+     * @since 4.2
      */
-    public void setAuthScheme(final AuthScheme authScheme) {
+    public void update(final AuthScheme authScheme, final Credentials credentials) {
         if (authScheme == null) {
-            reset();
-            return;
+            throw new IllegalArgumentException("Auth scheme may not be null or empty");
+        }
+        if (credentials == null) {
+            throw new IllegalArgumentException("Credentials may not be null or empty");
         }
         this.authScheme = authScheme;
+        this.credentials = credentials;
+        this.authOptions = null;
     }
 
     /**
-     * Returns the {@link AuthScheme authentication scheme}.
+     * Returns available {@link AuthOption}s. May be null.
      *
-     * @return {@link AuthScheme authentication scheme}
+     * @since 4.2
      */
-    public AuthScheme getAuthScheme() {
-        return this.authScheme;
+    public Queue<AuthOption> getAuthOptions() {
+        return this.authOptions;
     }
 
     /**
+     * Returns <code>true</code> if {@link AuthOption}s are available, <code>false</code>
+     * otherwise.
+     *
      * @since 4.2
      */
-    public AuthProtocolState getState() {
-        return this.state;
+    public boolean hasAuthOptions() {
+        return this.authOptions != null && !this.authOptions.isEmpty();
     }
 
     /**
+     * Updates the auth state with a queue of {@link AuthOption}s.
+     *
+     * @param authOptions a queue of auth options. May not be null or empty.
+     *
      * @since 4.2
      */
-    public void setState(final AuthProtocolState state) {
-        this.state = state != null ? state : AuthProtocolState.UNCHALLENGED;
+    public void update(final Queue<AuthOption> authOptions) {
+        if (authOptions == null || authOptions.isEmpty()) {
+            throw new IllegalArgumentException("Queue of auth options may not be null or
empty");
+        }
+        this.authOptions = authOptions;
+        this.authScheme = null;
+        this.credentials = null;
     }
 
     /**
-     * Returns user {@link Credentials} selected for authentication if available
+     * Invalidates the authentication state by resetting its parameters.
      *
-     * @return user credentials if available, <code>null</code otherwise
+     * @deprecated use {@link #reset()}
      */
-    public Credentials getCredentials() {
-        return this.credentials;
+    @Deprecated
+    public void invalidate() {
+        reset();
+    }
+
+    @Deprecated
+    public boolean isValid() {
+        return this.authScheme != null;
+    }
+
+    /**
+     * Assigns the given {@link AuthScheme authentication scheme}.
+     *
+     * @param authScheme the {@link AuthScheme authentication scheme}
+     *
+     * @deprecated use {@link #update(AuthScheme, Credentials)}
+     */
+    @Deprecated
+    public void setAuthScheme(final AuthScheme authScheme) {
+        if (authScheme == null) {
+            reset();
+            return;
+        }
+        this.authScheme = authScheme;
     }
 
     /**
      * Sets user {@link Credentials} to be used for authentication
      *
      * @param credentials User credentials
+     *
+     * @deprecated use {@link #update(AuthScheme, Credentials)}
      */
+    @Deprecated
     public void setCredentials(final Credentials credentials) {
         this.credentials = credentials;
     }
@@ -162,41 +221,6 @@ public class AuthState {
         this.authScope = authScope;
     }
 
-    /**
-     * Returns available authentication options.
-     *
-     * @return authentication options, if available, <code>null</null> otherwise.
-     *
-     * @since 4.2
-     */
-    public Queue<AuthOption> getAuthOptions() {
-        return this.authOptions;
-    }
-
-    /**
-     * Returns <code>true</code> if authentication options are available, <code>false</code>
-     * otherwise.
-     *
-     * @return <code>true</code> if authentication options are available, <code>false</code>
-     * otherwise.
-     *
-     * @since 4.2
-     */
-    public boolean hasAuthOptions() {
-        return this.authOptions != null && !this.authOptions.isEmpty();
-    }
-
-    /**
-     * Sets authentication options to select from when authenticating.
-     *
-     * @param authOptions authentication options
-     *
-     * @since 4.2
-     */
-    public void setAuthOptions(final Queue<AuthOption> authOptions) {
-        this.authOptions = authOptions != null && !authOptions.isEmpty() ? authOptions
: null;
-    }
-
     @Override
     public String toString() {
         StringBuilder buffer = new StringBuilder();

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
Wed Oct 12 11:45:54 2011
@@ -127,8 +127,7 @@ public class RequestAuthCache implements
         Credentials creds = credsProvider.getCredentials(authScope);
 
         if (creds != null) {
-            authState.setAuthScheme(authScheme);
-            authState.setCredentials(creds);
+            authState.update(authScheme, creds);
         } else {
             this.log.debug("No credentials for preemptive authentication");
         }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthenticationBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthenticationBase.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthenticationBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/RequestAuthenticationBase.java
Wed Oct 12 11:45:54 2011
@@ -74,8 +74,7 @@ abstract class RequestAuthenticationBase
                     AuthOption authOption = authOptions.remove();
                     authScheme = authOption.getAuthScheme();
                     creds = authOption.getCredentials();
-                    authState.setAuthScheme(authScheme);
-                    authState.setCredentials(creds);
+                    authState.update(authScheme, creds);
                     if (this.log.isDebugEnabled()) {
                         this.log.debug("Generating response to an authentication challenge
using "
                                 + authScheme.getSchemeName() + " scheme");
@@ -83,7 +82,6 @@ abstract class RequestAuthenticationBase
                     try {
                         Header header = authenticate(authScheme, creds, request, context);
                         request.addHeader(header);
-                        authState.setAuthOptions(null);
                         break;
                     } catch (AuthenticationException ex) {
                         if (this.log.isWarnEnabled()) {

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpAuthenticator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpAuthenticator.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpAuthenticator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/HttpAuthenticator.java
Wed Oct 12 11:45:54 2011
@@ -134,7 +134,7 @@ public class HttpAuthenticator {
             Queue<AuthOption> authOptions = authStrategy.select(challenges, host, response,
context);
             if (authOptions != null && !authOptions.isEmpty()) {
                 authState.setState(AuthProtocolState.CHALLENGED);
-                authState.setAuthOptions(authOptions);
+                authState.update(authOptions);
                 return true;
             } else {
                 return false;

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthCache.java
Wed Oct 12 11:45:54 2011
@@ -232,11 +232,9 @@ public class TestRequestAuthCache {
         context.setAttribute(ClientContext.AUTH_CACHE, authCache);
 
         this.targetState.setState(AuthProtocolState.CHALLENGED);
-        this.targetState.setAuthScheme(new BasicScheme());
-        this.targetState.setCredentials(new UsernamePasswordCredentials("user3", "secret3"));
-        this.proxyState.setAuthScheme(new BasicScheme());
-        this.proxyState.setCredentials(new UsernamePasswordCredentials("user4", "secret4"));
+        this.targetState.update(new BasicScheme(), new UsernamePasswordCredentials("user3",
"secret3"));
         this.proxyState.setState(AuthProtocolState.CHALLENGED);
+        this.proxyState.update(new BasicScheme(), new UsernamePasswordCredentials("user4",
"secret4"));
 
         HttpRequestInterceptor interceptor = new RequestAuthCache();
         interceptor.process(request, context);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthenticationBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthenticationBase.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthenticationBase.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestAuthenticationBase.java
Wed Oct 12 11:45:54 2011
@@ -82,7 +82,7 @@ public class TestRequestAuthenticationBa
     public void testAuthFailureState() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/");
         this.authState.setState(AuthProtocolState.FAILURE);
-        this.authState.setAuthScheme(this.authScheme);
+        this.authState.update(this.authScheme, this.credentials);
 
         this.interceptor.process(request, this.context);
 
@@ -98,8 +98,7 @@ public class TestRequestAuthenticationBa
     public void testAuthChallengeStateNoOption() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/");
         this.authState.setState(AuthProtocolState.CHALLENGED);
-        this.authState.setAuthScheme(this.authScheme);
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(this.authScheme, this.credentials);
 
         Mockito.when(this.authScheme.authenticate(
                 Mockito.any(Credentials.class),
@@ -119,7 +118,7 @@ public class TestRequestAuthenticationBa
         this.authState.setState(AuthProtocolState.CHALLENGED);
         LinkedList<AuthOption> authOptions = new LinkedList<AuthOption>();
         authOptions.add(new AuthOption(this.authScheme, this.credentials));
-        this.authState.setAuthOptions(authOptions);
+        this.authState.update(authOptions);
 
         Mockito.when(this.authScheme.authenticate(
                 Mockito.any(Credentials.class),
@@ -155,7 +154,7 @@ public class TestRequestAuthenticationBa
                 Mockito.any(HttpContext.class))).thenReturn(new BasicHeader(AUTH.WWW_AUTH_RESP,
"stuff"));
         authOptions.add(new AuthOption(authScheme1, this.credentials));
         authOptions.add(new AuthOption(authScheme2, this.credentials));
-        this.authState.setAuthOptions(authOptions);
+        this.authState.update(authOptions);
 
         this.interceptor.process(request, this.context);
 
@@ -173,9 +172,7 @@ public class TestRequestAuthenticationBa
     public void testAuthSuccess() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/");
         this.authState.setState(AuthProtocolState.SUCCESS);
-
-        this.authState.setAuthScheme(this.authScheme);
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(this.authScheme, this.credentials);
 
         Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.FALSE);
         Mockito.when(this.authScheme.authenticate(
@@ -198,9 +195,7 @@ public class TestRequestAuthenticationBa
     public void testAuthSuccessConnectionBased() throws Exception {
         HttpRequest request = new BasicHttpRequest("GET", "/");
         this.authState.setState(AuthProtocolState.SUCCESS);
-
-        this.authState.setAuthScheme(this.authScheme);
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(this.authScheme, this.credentials);
 
         Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.TRUE);
         Mockito.when(this.authScheme.authenticate(

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestProxyAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestProxyAuthentication.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestProxyAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestProxyAuthentication.java
Wed Oct 12 11:45:54 2011
@@ -85,8 +85,7 @@ public class TestRequestProxyAuthenticat
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate);
@@ -118,8 +117,7 @@ public class TestRequestProxyAuthenticat
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate);
@@ -151,8 +149,7 @@ public class TestRequestProxyAuthenticat
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate);
@@ -239,9 +236,8 @@ public class TestRequestProxyAuthenticat
 
         Credentials creds = new UsernamePasswordCredentials("user", "secret");
 
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
         authstate.setState(AuthProtocolState.SUCCESS);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
         context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestTargetAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestTargetAuthentication.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestTargetAuthentication.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestRequestTargetAuthentication.java
Wed Oct 12 11:45:54 2011
@@ -70,8 +70,7 @@ public class TestRequestTargetAuthentica
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate);
 
@@ -93,8 +92,7 @@ public class TestRequestTargetAuthentica
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate);
 
@@ -117,8 +115,7 @@ public class TestRequestTargetAuthentica
         authscheme.processChallenge(challenge);
 
         AuthState authstate = new AuthState();
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate);
 
@@ -178,9 +175,8 @@ public class TestRequestTargetAuthentica
 
         Credentials creds = new UsernamePasswordCredentials("user", "secret");
 
-        authstate.setAuthScheme(authscheme);
-        authstate.setCredentials(creds);
         authstate.setState(AuthProtocolState.SUCCESS);
+        authstate.update(authscheme, creds);
 
         context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate);
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/client/protocol/TestResponseAuthCache.java
Wed Oct 12 11:45:54 2011
@@ -35,6 +35,8 @@ import org.apache.http.HttpVersion;
 import org.apache.http.auth.AUTH;
 import org.apache.http.auth.AuthProtocolState;
 import org.apache.http.auth.AuthState;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.AuthCache;
 import org.apache.http.impl.auth.BasicScheme;
 import org.apache.http.impl.client.BasicAuthCache;
@@ -52,6 +54,7 @@ public class TestResponseAuthCache {
     private HttpHost proxy;
     private BasicScheme authscheme1;
     private BasicScheme authscheme2;
+    private Credentials credentials;
     private AuthState targetState;
     private AuthState proxyState;
 
@@ -62,6 +65,7 @@ public class TestResponseAuthCache {
 
         this.authscheme1 = new BasicScheme();
         this.authscheme2 = new BasicScheme();
+        this.credentials = new UsernamePasswordCredentials("user", "pwd");
 
         this.targetState = new AuthState();
         this.proxyState = new AuthState();
@@ -91,10 +95,10 @@ public class TestResponseAuthCache {
                 new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
 
         this.targetState.setState(AuthProtocolState.CHALLENGED);
-        this.targetState.setAuthScheme(this.authscheme1);
+        this.targetState.update(this.authscheme1, this.credentials);
 
         this.proxyState.setState(AuthProtocolState.CHALLENGED);
-        this.proxyState.setAuthScheme(this.authscheme2);
+        this.proxyState.update(this.authscheme2, this.credentials);
 
         HttpContext context = new BasicHttpContext();
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
@@ -148,10 +152,10 @@ public class TestResponseAuthCache {
         HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
 
         this.targetState.setState(AuthProtocolState.CHALLENGED);
-        this.targetState.setAuthScheme(this.authscheme1);
+        this.targetState.update(this.authscheme1, this.credentials);
 
         this.proxyState.setState(AuthProtocolState.CHALLENGED);
-        this.proxyState.setAuthScheme(this.authscheme2);
+        this.proxyState.update(this.authscheme2, this.credentials);
 
         HttpContext context = new BasicHttpContext();
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
@@ -176,10 +180,10 @@ public class TestResponseAuthCache {
                 new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
 
         this.targetState.setState(AuthProtocolState.UNCHALLENGED);
-        this.targetState.setAuthScheme(this.authscheme1);
+        this.targetState.update(this.authscheme1, this.credentials);
 
         this.proxyState.setState(AuthProtocolState.UNCHALLENGED);
-        this.proxyState.setAuthScheme(this.authscheme2);
+        this.proxyState.update(this.authscheme2, this.credentials);
 
         HttpContext context = new BasicHttpContext();
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);
@@ -206,10 +210,10 @@ public class TestResponseAuthCache {
                 new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
 
         this.targetState.setState(AuthProtocolState.FAILURE);
-        this.targetState.setAuthScheme(this.authscheme1);
+        this.targetState.update(this.authscheme1, this.credentials);
 
         this.proxyState.setState(AuthProtocolState.FAILURE);
-        this.proxyState.setAuthScheme(this.authscheme2);
+        this.proxyState.update(this.authscheme2, this.credentials);
 
         HttpContext context = new BasicHttpContext();
         context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, this.target);

Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestHttpAuthenticator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestHttpAuthenticator.java?rev=1182317&r1=1182316&r2=1182317&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestHttpAuthenticator.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/client/TestHttpAuthenticator.java
Wed Oct 12 11:45:54 2011
@@ -248,8 +248,7 @@ public class TestHttpAuthenticator {
         TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
 
         this.authState.setState(AuthProtocolState.CHALLENGED);
-        this.authState.setAuthScheme(new BasicScheme());
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(new BasicScheme(), this.credentials);
 
         Assert.assertFalse(this.httpAuthenticator.authenticate(host,
                 response, authStrategy, this.authState, this.context));
@@ -268,8 +267,7 @@ public class TestHttpAuthenticator {
         TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
 
         this.authState.setState(AuthProtocolState.CHALLENGED);
-        this.authState.setAuthScheme(new DigestScheme());
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(new DigestScheme(), this.credentials);
 
         Assert.assertTrue(this.httpAuthenticator.authenticate(host,
                 response, authStrategy, this.authState, this.context));
@@ -286,8 +284,7 @@ public class TestHttpAuthenticator {
         TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
 
         this.authState.setState(AuthProtocolState.CHALLENGED);
-        this.authState.setAuthScheme(new BasicScheme());
-        this.authState.setCredentials(this.credentials);
+        this.authState.update(new BasicScheme(), this.credentials);
 
         Assert.assertTrue(this.httpAuthenticator.authenticate(host,
                 response, authStrategy, this.authState, this.context));



Mime
View raw message