You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2015/08/07 09:33:53 UTC
svn commit: r1694619 - 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/auth/ main/java/org/apache/http/impl/client/
main/java/org/apache/http/...
Author: olegk
Date: Fri Aug 7 07:33:52 2015
New Revision: 1694619
URL: http://svn.apache.org/r1694619
Log:
Redesigned auth handshake state management
Added:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java (contents, props changed)
- copied, changed from r1692468, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
Removed:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthProtocolState.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java
Modified:
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.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/impl/auth/HttpAuthenticator.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.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/impl/auth/TestHttpAuthenticator.java
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java (from r1692468, 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/AuthExchange.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthState.java&r1=1692468&r2=1694619&rev=1694619&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/AuthExchange.java Fri Aug 7 07:33:52 2015
@@ -32,50 +32,41 @@ import org.apache.http.annotation.NotThr
import org.apache.http.util.Args;
/**
- * This class provides detailed information about the state of the authentication process.
+ * This class represents the actual state of authentication handshake including the current {@link AuthScheme}
+ * used for request authorization as well as a collection of backup authentication options if available.
*
- * @since 4.0
+ * @since 4.5
*/
@NotThreadSafe
-public class AuthState {
+public class AuthExchange {
- /** Actual state of authentication protocol */
- private AuthProtocolState state;
+ public enum State {
- /** Actual authentication scheme */
- private AuthScheme authScheme;
+ UNCHALLENGED, CHALLENGED, HANDSHAKE, FAILURE, SUCCESS
+
+ }
- /** Available auth options */
+ private State state;
+ private AuthScheme authScheme;
private Queue<AuthScheme> authOptions;
- public AuthState() {
+ public AuthExchange() {
super();
- this.state = AuthProtocolState.UNCHALLENGED;
+ this.state = State.UNCHALLENGED;
}
- /**
- * Resets the auth state.
- *
- * @since 4.2
- */
public void reset() {
- this.state = AuthProtocolState.UNCHALLENGED;
+ this.state = State.UNCHALLENGED;
this.authOptions = null;
this.authScheme = null;
}
- /**
- * @since 4.2
- */
- public AuthProtocolState getState() {
+ public State getState() {
return this.state;
}
- /**
- * @since 4.2
- */
- public void setState(final AuthProtocolState state) {
- this.state = state != null ? state : AuthProtocolState.UNCHALLENGED;
+ public void setState(final State state) {
+ this.state = state != null ? state : State.UNCHALLENGED;
}
/**
@@ -86,13 +77,11 @@ public class AuthState {
}
/**
- * Updates the auth state with {@link AuthScheme} and clears auth options.
+ * Resets the auth state with {@link AuthScheme} and clears auth options.
*
* @param authScheme auth scheme. May not be null.
- *
- * @since 4.2
*/
- public void update(final AuthScheme authScheme) {
+ public void select(final AuthScheme authScheme) {
Args.notNull(authScheme, "Auth scheme");
this.authScheme = authScheme;
this.authOptions = null;
@@ -100,8 +89,6 @@ public class AuthState {
/**
* Returns available auth options. May be null.
- *
- * @since 4.2
*/
public Queue<AuthScheme> getAuthOptions() {
return this.authOptions;
@@ -111,13 +98,10 @@ public class AuthState {
* Updates the auth state with a queue of auth options.
*
* @param authOptions a queue of auth options. May not be null or empty.
- *
- * @since 4.2
*/
- public void update(final Queue<AuthScheme> authOptions) {
+ public void setOptions(final Queue<AuthScheme> authOptions) {
Args.notEmpty(authOptions, "Queue of auth options");
this.authOptions = authOptions;
- this.authScheme = null;
}
@Override
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/auth/AuthExchange.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/protocol/HttpClientContext.java Fri Aug 7 07:33:52 2015
@@ -31,8 +31,8 @@ import java.net.URI;
import java.util.List;
import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthState;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.AuthCache;
import org.apache.http.client.CookieStore;
@@ -106,13 +106,13 @@ public class HttpClientContext extends H
public static final String AUTH_CACHE = "http.auth.auth-cache";
/**
- * Attribute name of a {@link org.apache.http.auth.AuthState}
+ * Attribute name of a {@link org.apache.http.auth.AuthExchange}
* object that represents the actual target authentication state.
*/
public static final String TARGET_AUTH_STATE = "http.auth.target-scope";
/**
- * Attribute name of a {@link org.apache.http.auth.AuthState}
+ * Attribute name of a {@link org.apache.http.auth.AuthExchange}
* object that represents the actual proxy authentication state.
*/
public static final String PROXY_AUTH_STATE = "http.auth.proxy-scope";
@@ -217,12 +217,12 @@ public class HttpClientContext extends H
setAttribute(AUTH_CACHE, authCache);
}
- public AuthState getTargetAuthState() {
- return getAttribute(TARGET_AUTH_STATE, AuthState.class);
+ public AuthExchange getTargetAuthState() {
+ return getAttribute(TARGET_AUTH_STATE, AuthExchange.class);
}
- public AuthState getProxyAuthState() {
- return getAttribute(PROXY_AUTH_STATE, AuthState.class);
+ public AuthExchange getProxyAuthState() {
+ return getAttribute(PROXY_AUTH_STATE, AuthExchange.class);
}
public <T> T getUserToken(final Class<T> clazz) {
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=1694619&r1=1694618&r2=1694619&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 Fri Aug 7 07:33:52 2015
@@ -36,9 +36,8 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.AuthCache;
import org.apache.http.conn.routing.RouteInfo;
@@ -100,26 +99,26 @@ public class RequestAuthCache implements
target.getSchemeName());
}
- final AuthState targetState = clientContext.getTargetAuthState();
- if (targetState != null && targetState.getState() == AuthProtocolState.UNCHALLENGED) {
+ final AuthExchange targetState = clientContext.getTargetAuthState();
+ if (targetState != null && targetState.getState() == AuthExchange.State.UNCHALLENGED) {
final AuthScheme authScheme = authCache.get(target);
if (authScheme != null) {
if (this.log.isDebugEnabled()) {
this.log.debug("Re-using cached '" + authScheme.getName() + "' auth scheme for " + target);
}
- targetState.update(authScheme);
+ targetState.select(authScheme);
}
}
final HttpHost proxy = route.getProxyHost();
- final AuthState proxyState = clientContext.getProxyAuthState();
- if (proxy != null && proxyState != null && proxyState.getState() == AuthProtocolState.UNCHALLENGED) {
+ final AuthExchange proxyState = clientContext.getProxyAuthState();
+ if (proxy != null && proxyState != null && proxyState.getState() == AuthExchange.State.UNCHALLENGED) {
final AuthScheme authScheme = authCache.get(proxy);
if (authScheme != null) {
if (this.log.isDebugEnabled()) {
this.log.debug("Re-using cached '" + authScheme.getName() + "' auth scheme for " + proxy);
}
- proxyState.update(authScheme);
+ proxyState.select(authScheme);
}
}
}
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java Fri Aug 7 07:33:52 2015
@@ -47,9 +47,8 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ParseException;
import org.apache.http.auth.AuthChallenge;
-import org.apache.http.auth.AuthProtocolState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ChallengeType;
import org.apache.http.auth.CredentialsProvider;
@@ -86,7 +85,7 @@ public class HttpAuthenticator {
final HttpHost host,
final ChallengeType challengeType,
final HttpResponse response,
- final AuthState authState,
+ final AuthExchange authState,
final HttpContext context) {
final int challengeCode;
switch (challengeType) {
@@ -104,7 +103,7 @@ public class HttpAuthenticator {
if (response.getStatusLine().getStatusCode() == challengeCode) {
this.log.debug("Authentication required");
- if (authState.getState() == AuthProtocolState.SUCCESS) {
+ if (authState.getState() == AuthExchange.State.SUCCESS) {
clearCache(host, clientContext);
}
return true;
@@ -113,13 +112,13 @@ public class HttpAuthenticator {
case CHALLENGED:
case HANDSHAKE:
this.log.debug("Authentication succeeded");
- authState.setState(AuthProtocolState.SUCCESS);
+ authState.setState(AuthExchange.State.SUCCESS);
updateCache(host, authState.getAuthScheme(), clientContext);
break;
case SUCCESS:
break;
default:
- authState.setState(AuthProtocolState.UNCHALLENGED);
+ authState.setState(AuthExchange.State.UNCHALLENGED);
}
return false;
}
@@ -130,7 +129,7 @@ public class HttpAuthenticator {
final ChallengeType challengeType,
final HttpResponse response,
final AuthenticationStrategy authStrategy,
- final AuthState authState,
+ final AuthExchange authState,
final HttpContext context) {
if (this.log.isDebugEnabled()) {
@@ -211,10 +210,10 @@ public class HttpAuthenticator {
this.log.debug("Authentication failed");
clearCache(host, clientContext);
authState.reset();
- authState.setState(AuthProtocolState.FAILURE);
+ authState.setState(AuthExchange.State.FAILURE);
return false;
} else {
- authState.setState(AuthProtocolState.HANDSHAKE);
+ authState.setState(AuthExchange.State.HANDSHAKE);
return true;
}
} else {
@@ -250,8 +249,9 @@ public class HttpAuthenticator {
if (this.log.isDebugEnabled()) {
this.log.debug("Selected authentication options: " + authOptions);
}
- authState.setState(AuthProtocolState.CHALLENGED);
- authState.update(authOptions);
+ authState.reset();
+ authState.setState(AuthExchange.State.CHALLENGED);
+ authState.setOptions(authOptions);
return true;
} else {
return false;
@@ -262,7 +262,7 @@ public class HttpAuthenticator {
final HttpHost host,
final ChallengeType challengeType,
final HttpRequest request,
- final AuthState authState,
+ final AuthExchange authState,
final HttpContext context) throws HttpException, IOException {
AuthScheme authScheme = authState.getAuthScheme();
switch (authState.getState()) {
@@ -282,7 +282,7 @@ public class HttpAuthenticator {
if (authOptions != null) {
while (!authOptions.isEmpty()) {
authScheme = authOptions.remove();
- authState.update(authScheme);
+ authState.select(authScheme);
if (this.log.isDebugEnabled()) {
this.log.debug("Generating response to an authentication challenge using "
+ authScheme.getName() + " scheme");
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java Fri Aug 7 07:33:52 2015
@@ -33,7 +33,7 @@ import javax.net.ssl.SSLSession;
import org.apache.http.HttpConnection;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.client.UserTokenHandler;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.ManagedHttpClientConnection;
@@ -65,11 +65,11 @@ public class DefaultUserTokenHandler imp
Principal userPrincipal = null;
- final AuthState targetAuthState = clientContext.getTargetAuthState();
+ final AuthExchange targetAuthState = clientContext.getTargetAuthState();
if (targetAuthState != null) {
userPrincipal = getAuthPrincipal(targetAuthState);
if (userPrincipal == null) {
- final AuthState proxyAuthState = clientContext.getProxyAuthState();
+ final AuthExchange proxyAuthState = clientContext.getProxyAuthState();
userPrincipal = getAuthPrincipal(proxyAuthState);
}
}
@@ -87,7 +87,7 @@ public class DefaultUserTokenHandler imp
return userPrincipal;
}
- private static Principal getAuthPrincipal(final AuthState authState) {
+ private static Principal getAuthPrincipal(final AuthExchange authState) {
final AuthScheme scheme = authState.getAuthScheme();
if (scheme != null && scheme.isConnectionBased()) {
return scheme.getPrinciple();
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/InternalHttpClient.java Fri Aug 7 07:33:52 2015
@@ -38,7 +38,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.CredentialsProvider;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.CookieStore;
@@ -112,10 +112,10 @@ class InternalHttpClient extends Closeab
private void setupContext(final HttpClientContext context) {
if (context.getAttribute(HttpClientContext.TARGET_AUTH_STATE) == null) {
- context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, new AuthState());
+ context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, new AuthExchange());
}
if (context.getAttribute(HttpClientContext.PROXY_AUTH_STATE) == null) {
- context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, new AuthState());
+ context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, new AuthExchange());
}
if (context.getAttribute(HttpClientContext.AUTHSCHEME_REGISTRY) == null) {
context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/ProxyClient.java Fri Aug 7 07:33:52 2015
@@ -40,7 +40,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.ChallengeType;
import org.apache.http.auth.Credentials;
import org.apache.http.client.AuthenticationStrategy;
@@ -90,7 +90,7 @@ public class ProxyClient {
private final HttpRequestExecutor requestExec;
private final AuthenticationStrategy proxyAuthStrategy;
private final HttpAuthenticator authenticator;
- private final AuthState proxyAuthState;
+ private final AuthExchange proxyAuthState;
private final Lookup<AuthSchemeProvider> authSchemeRegistry;
private final ConnectionReuseStrategy reuseStrategy;
@@ -110,7 +110,7 @@ public class ProxyClient {
this.requestExec = new HttpRequestExecutor();
this.proxyAuthStrategy = new DefaultAuthenticationStrategy();
this.authenticator = new HttpAuthenticator();
- this.proxyAuthState = new AuthState();
+ this.proxyAuthState = new AuthExchange();
this.authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.BASIC, new BasicSchemeFactory())
.register(AuthSchemes.DIGEST, new DigestSchemeFactory())
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/MainClientExec.java Fri Aug 7 07:33:52 2015
@@ -44,8 +44,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthProtocolState;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.ChallengeType;
import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.NonRepeatableRequestException;
@@ -155,14 +154,14 @@ public class MainClientExec implements C
Args.notNull(request, "HTTP request");
Args.notNull(context, "HTTP context");
- AuthState targetAuthState = context.getTargetAuthState();
+ AuthExchange targetAuthState = context.getTargetAuthState();
if (targetAuthState == null) {
- targetAuthState = new AuthState();
+ targetAuthState = new AuthExchange();
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, targetAuthState);
}
- AuthState proxyAuthState = context.getProxyAuthState();
+ AuthExchange proxyAuthState = context.getProxyAuthState();
if (proxyAuthState == null) {
- proxyAuthState = new AuthState();
+ proxyAuthState = new AuthExchange();
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
}
@@ -293,13 +292,13 @@ public class MainClientExec implements C
EntityUtils.consume(entity);
} else {
managedConn.close();
- if (proxyAuthState.getState() == AuthProtocolState.SUCCESS
+ if (proxyAuthState.getState() == AuthExchange.State.SUCCESS
&& proxyAuthState.getAuthScheme() != null
&& proxyAuthState.getAuthScheme().isConnectionBased()) {
this.log.debug("Resetting proxy auth state");
proxyAuthState.reset();
}
- if (targetAuthState.getState() == AuthProtocolState.SUCCESS
+ if (targetAuthState.getState() == AuthExchange.State.SUCCESS
&& targetAuthState.getAuthScheme() != null
&& targetAuthState.getAuthScheme().isConnectionBased()) {
this.log.debug("Resetting target auth state");
@@ -351,7 +350,7 @@ public class MainClientExec implements C
* Establishes the target route.
*/
void establishRoute(
- final AuthState proxyAuthState,
+ final AuthExchange proxyAuthState,
final HttpClientConnection managedConn,
final HttpRoute route,
final HttpRequest request,
@@ -429,7 +428,7 @@ public class MainClientExec implements C
* information about the tunnel, that is left to the caller.
*/
private boolean createTunnelToTarget(
- final AuthState proxyAuthState,
+ final AuthExchange proxyAuthState,
final HttpClientConnection managedConn,
final HttpRoute route,
final HttpRequest request,
@@ -532,8 +531,8 @@ public class MainClientExec implements C
}
private boolean needAuthentication(
- final AuthState targetAuthState,
- final AuthState proxyAuthState,
+ final AuthExchange targetAuthState,
+ final AuthExchange proxyAuthState,
final HttpRoute route,
final HttpResponse response,
final HttpClientContext context) {
Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/execchain/RedirectExec.java Fri Aug 7 07:33:52 2015
@@ -40,7 +40,7 @@ import org.apache.http.HttpRequest;
import org.apache.http.ProtocolException;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.client.RedirectException;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
@@ -139,12 +139,12 @@ public class RedirectExec implements Cli
// Reset virtual host and auth states if redirecting to another host
if (!currentRoute.getTargetHost().equals(newTarget)) {
- final AuthState targetAuthState = context.getTargetAuthState();
+ final AuthExchange targetAuthState = context.getTargetAuthState();
if (targetAuthState != null) {
this.log.debug("Resetting target auth state");
targetAuthState.reset();
}
- final AuthState proxyAuthState = context.getProxyAuthState();
+ final AuthExchange proxyAuthState = context.getProxyAuthState();
if (proxyAuthState != null) {
final AuthScheme authScheme = proxyAuthState.getAuthScheme();
if (authScheme != null && authScheme.isConnectionBased()) {
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=1694619&r1=1694618&r2=1694619&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 Fri Aug 7 07:33:52 2015
@@ -29,9 +29,8 @@ package org.apache.http.client.protocol;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
@@ -56,8 +55,8 @@ public class TestRequestAuthCache {
private BasicScheme authscheme1;
private BasicScheme authscheme2;
private BasicCredentialsProvider credProvider;
- private AuthState targetState;
- private AuthState proxyState;
+ private AuthExchange targetState;
+ private AuthExchange proxyState;
@Before
public void setUp() {
@@ -75,8 +74,8 @@ public class TestRequestAuthCache {
this.credProvider.setCredentials(this.authscope1, this.creds1);
this.credProvider.setCredentials(this.authscope2, this.creds2);
- this.targetState = new AuthState();
- this.proxyState = new AuthState();
+ this.targetState = new AuthExchange();
+ this.proxyState = new AuthExchange();
}
@Test(expected=IllegalArgumentException.class)
@@ -194,10 +193,10 @@ public class TestRequestAuthCache {
context.setAttribute(HttpClientContext.AUTH_CACHE, authCache);
- this.targetState.setState(AuthProtocolState.CHALLENGED);
- this.targetState.update(new BasicScheme());
- this.proxyState.setState(AuthProtocolState.CHALLENGED);
- this.proxyState.update(new BasicScheme());
+ this.targetState.setState(AuthExchange.State.CHALLENGED);
+ this.targetState.select(new BasicScheme());
+ this.proxyState.setState(AuthExchange.State.CHALLENGED);
+ this.proxyState.select(new BasicScheme());
final HttpRequestInterceptor interceptor = new RequestAuthCache();
interceptor.process(request, context);
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/auth/TestHttpAuthenticator.java Fri Aug 7 07:33:52 2015
@@ -35,11 +35,10 @@ import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.HttpVersion;
-import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthSchemeProvider;
import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ChallengeType;
import org.apache.http.auth.Credentials;
@@ -64,7 +63,7 @@ import org.mockito.Mockito;
@SuppressWarnings({"boxing","static-access"})
public class TestHttpAuthenticator {
- private AuthState authState;
+ private AuthExchange authState;
private AuthScheme authScheme;
private HttpContext context;
private HttpHost defaultHost;
@@ -75,7 +74,7 @@ public class TestHttpAuthenticator {
@Before
public void setUp() throws Exception {
- this.authState = new AuthState();
+ this.authState = new AuthExchange();
this.authScheme = Mockito.mock(AuthScheme.class);
Mockito.when(this.authScheme.getName()).thenReturn("Basic");
Mockito.when(this.authScheme.isChallengeComplete()).thenReturn(Boolean.TRUE);
@@ -108,8 +107,8 @@ public class TestHttpAuthenticator {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
response.setHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=test");
- this.authState.update(this.authScheme);
- this.authState.setState(AuthProtocolState.SUCCESS);
+ this.authState.select(this.authScheme);
+ this.authState.setState(AuthExchange.State.SUCCESS);
Assert.assertTrue(this.httpAuthenticator.isChallenged(
this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context));
@@ -123,18 +122,18 @@ public class TestHttpAuthenticator {
Assert.assertFalse(this.httpAuthenticator.isChallenged(
this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.UNCHALLENGED, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authState.getState());
}
@Test
public void testAuthenticationNotRequestedSuccess1() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
- this.authState.update(this.authScheme);
- this.authState.setState(AuthProtocolState.CHALLENGED);
+ this.authState.select(this.authScheme);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
Assert.assertFalse(this.httpAuthenticator.isChallenged(
this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.SUCCESS, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.SUCCESS, this.authState.getState());
Mockito.verify(this.authCache).put(this.defaultHost, this.authScheme);
}
@@ -142,12 +141,12 @@ public class TestHttpAuthenticator {
@Test
public void testAuthenticationNotRequestedSuccess2() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
- this.authState.update(this.authScheme);
- this.authState.setState(AuthProtocolState.HANDSHAKE);
+ this.authState.select(this.authScheme);
+ this.authState.setState(AuthExchange.State.HANDSHAKE);
Assert.assertFalse(this.httpAuthenticator.isChallenged(
this.defaultHost, ChallengeType.TARGET, response, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.SUCCESS, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.SUCCESS, this.authState.getState());
Mockito.verify(this.authCache).put(this.defaultHost, this.authScheme);
}
@@ -167,7 +166,7 @@ public class TestHttpAuthenticator {
Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.CHALLENGED, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState());
final Queue<AuthScheme> options = this.authState.getAuthOptions();
Assert.assertNotNull(options);
@@ -194,7 +193,7 @@ public class TestHttpAuthenticator {
Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.CHALLENGED, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState());
final Queue<AuthScheme> options = this.authState.getAuthOptions();
Assert.assertNotNull(options);
@@ -248,15 +247,15 @@ public class TestHttpAuthenticator {
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\""));
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\""));
- this.authState.setState(AuthProtocolState.CHALLENGED);
- this.authState.update(this.authScheme);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
+ this.authState.select(this.authScheme);
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.FAILURE, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState());
Mockito.verify(this.authCache).remove(host);
}
@@ -268,14 +267,14 @@ public class TestHttpAuthenticator {
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"test\""));
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "Digest realm=\"realm1\", nonce=\"1234\""));
- this.authState.setState(AuthProtocolState.FAILURE);
+ this.authState.setState(AuthExchange.State.FAILURE);
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.FAILURE, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState());
}
@Test
@@ -288,12 +287,12 @@ public class TestHttpAuthenticator {
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
- this.authState.setState(AuthProtocolState.CHALLENGED);
- this.authState.update(new BasicScheme());
+ this.authState.setState(AuthExchange.State.CHALLENGED);
+ this.authState.select(new BasicScheme());
Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.FAILURE, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.FAILURE, this.authState.getState());
}
@Test
@@ -306,13 +305,13 @@ public class TestHttpAuthenticator {
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
- this.authState.setState(AuthProtocolState.CHALLENGED);
- this.authState.update(new DigestScheme());
+ this.authState.setState(AuthExchange.State.CHALLENGED);
+ this.authState.select(new DigestScheme());
Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.HANDSHAKE, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.HANDSHAKE, this.authState.getState());
}
@Test
@@ -327,12 +326,12 @@ public class TestHttpAuthenticator {
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
- this.authState.setState(AuthProtocolState.CHALLENGED);
- this.authState.update(new BasicScheme());
+ this.authState.setState(AuthExchange.State.CHALLENGED);
+ this.authState.select(new BasicScheme());
Assert.assertTrue(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.CHALLENGED, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.CHALLENGED, this.authState.getState());
final Queue<AuthScheme> options = this.authState.getAuthOptions();
Assert.assertNotNull(options);
@@ -348,22 +347,22 @@ public class TestHttpAuthenticator {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "blah blah blah"));
- this.authState.setState(AuthProtocolState.CHALLENGED);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy();
Assert.assertFalse(this.httpAuthenticator.prepareAuthResponse(
host, ChallengeType.TARGET, response, authStrategy, this.authState, this.context));
- Assert.assertEquals(AuthProtocolState.UNCHALLENGED, this.authState.getState());
+ Assert.assertEquals(AuthExchange.State.UNCHALLENGED, this.authState.getState());
Assert.assertNull(this.authState.getAuthScheme());
}
@Test
public void testAuthFailureState() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.FAILURE);
- this.authState.update(this.authScheme);
+ this.authState.setState(AuthExchange.State.FAILURE);
+ this.authState.select(this.authScheme);
this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context);
@@ -378,8 +377,8 @@ public class TestHttpAuthenticator {
@Test
public void testAuthChallengeStateNoOption() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.CHALLENGED);
- this.authState.update(this.authScheme);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
+ this.authState.select(this.authScheme);
Mockito.when(this.authScheme.generateAuthResponse(
Mockito.eq(defaultHost),
@@ -394,10 +393,10 @@ public class TestHttpAuthenticator {
@Test
public void testAuthChallengeStateOneOptions() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.CHALLENGED);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
final LinkedList<AuthScheme> authOptions = new LinkedList<>();
authOptions.add(this.authScheme);
- this.authState.update(authOptions);
+ this.authState.setOptions(authOptions);
Mockito.when(this.authScheme.generateAuthResponse(
Mockito.eq(defaultHost),
@@ -415,7 +414,7 @@ public class TestHttpAuthenticator {
@Test
public void testAuthChallengeStateMultipleOption() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.CHALLENGED);
+ this.authState.setState(AuthExchange.State.CHALLENGED);
final LinkedList<AuthScheme> authOptions = new LinkedList<>();
final AuthScheme authScheme1 = Mockito.mock(AuthScheme.class);
@@ -430,7 +429,7 @@ public class TestHttpAuthenticator {
Mockito.any(HttpContext.class))).thenReturn("stuff");
authOptions.add(authScheme1);
authOptions.add(authScheme2);
- this.authState.update(authOptions);
+ this.authState.setOptions(authOptions);
this.httpAuthenticator.addAuthResponse(defaultHost, ChallengeType.TARGET, request, authState, context);
@@ -443,8 +442,8 @@ public class TestHttpAuthenticator {
@Test
public void testAuthSuccess() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.SUCCESS);
- this.authState.update(this.authScheme);
+ this.authState.setState(AuthExchange.State.SUCCESS);
+ this.authState.select(this.authScheme);
Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.FALSE);
Mockito.when(this.authScheme.generateAuthResponse(
@@ -463,8 +462,8 @@ public class TestHttpAuthenticator {
@Test
public void testAuthSuccessConnectionBased() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
- this.authState.setState(AuthProtocolState.SUCCESS);
- this.authState.update(this.authScheme);
+ this.authState.setState(AuthExchange.State.SUCCESS);
+ this.authState.select(this.authScheme);
Mockito.when(this.authScheme.isConnectionBased()).thenReturn(Boolean.TRUE);
Mockito.when(this.authScheme.generateAuthResponse(
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java Fri Aug 7 07:33:52 2015
@@ -46,10 +46,9 @@ import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.auth.AuthChallenge;
-import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.auth.ChallengeType;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthenticationStrategy;
@@ -439,9 +438,9 @@ public class TestMainClientExec {
.setStream(instream2)
.build());
- final AuthState proxyAuthState = new AuthState();
- proxyAuthState.setState(AuthProtocolState.SUCCESS);
- proxyAuthState.update(new NTLMScheme());
+ final AuthExchange proxyAuthState = new AuthExchange();
+ proxyAuthState.setState(AuthExchange.State.SUCCESS);
+ proxyAuthState.select(new NTLMScheme());
final HttpClientContext context = new HttpClientContext();
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
@@ -602,7 +601,7 @@ public class TestMainClientExec {
@Test
public void testEstablishDirectRoute() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -617,7 +616,7 @@ public class TestMainClientExec {
@Test
public void testEstablishRouteDirectProxy() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, false);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -632,7 +631,7 @@ public class TestMainClientExec {
@Test
public void testEstablishRouteViaProxyTunnel() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom()
@@ -666,7 +665,7 @@ public class TestMainClientExec {
@Test(expected = HttpException.class)
public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -683,7 +682,7 @@ public class TestMainClientExec {
@Test(expected = HttpException.class)
public void testEstablishRouteViaProxyTunnelFailure() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -710,7 +709,7 @@ public class TestMainClientExec {
@Test
public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnection() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -749,7 +748,7 @@ public class TestMainClientExec {
@Test
public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentConnection() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpRoute route = new HttpRoute(target, null, proxy, true);
final HttpClientContext context = new HttpClientContext();
final HttpRequestWrapper request = HttpRequestWrapper.wrap(new HttpGet("http://bar/test"));
@@ -789,7 +788,7 @@ public class TestMainClientExec {
@Test(expected = HttpException.class)
public void testEstablishRouteViaProxyTunnelMultipleHops() throws Exception {
- final AuthState authState = new AuthState();
+ final AuthExchange authState = new AuthExchange();
final HttpHost proxy1 = new HttpHost("this", 8888);
final HttpHost proxy2 = new HttpHost("that", 8888);
final HttpRoute route = new HttpRoute(target, null, new HttpHost[] {proxy1, proxy2},
Modified: httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java?rev=1694619&r1=1694618&r2=1694619&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java Fri Aug 7 07:33:52 2015
@@ -37,8 +37,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
-import org.apache.http.auth.AuthProtocolState;
-import org.apache.http.auth.AuthState;
+import org.apache.http.auth.AuthExchange;
import org.apache.http.client.RedirectException;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.config.RequestConfig;
@@ -236,12 +235,12 @@ public class TestRedirectExec {
final HttpRequestWrapper request = HttpRequestWrapper.wrap(get);
final HttpClientContext context = HttpClientContext.create();
- final AuthState targetAuthState = new AuthState();
- targetAuthState.setState(AuthProtocolState.SUCCESS);
- targetAuthState.update(new BasicScheme());
- final AuthState proxyAuthState = new AuthState();
- proxyAuthState.setState(AuthProtocolState.SUCCESS);
- proxyAuthState.update(new NTLMScheme());
+ final AuthExchange targetAuthState = new AuthExchange();
+ targetAuthState.setState(AuthExchange.State.SUCCESS);
+ targetAuthState.select(new BasicScheme());
+ final AuthExchange proxyAuthState = new AuthExchange();
+ proxyAuthState.setState(AuthExchange.State.SUCCESS);
+ proxyAuthState.select(new NTLMScheme());
context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, targetAuthState);
context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, proxyAuthState);
@@ -274,10 +273,10 @@ public class TestRedirectExec {
redirectExec.execute(route, request, context, execAware);
Assert.assertNotNull(context.getTargetAuthState());
- Assert.assertEquals(AuthProtocolState.UNCHALLENGED, context.getTargetAuthState().getState());
+ Assert.assertEquals(AuthExchange.State.UNCHALLENGED, context.getTargetAuthState().getState());
Assert.assertEquals(null, context.getTargetAuthState().getAuthScheme());
Assert.assertNotNull(context.getProxyAuthState());
- Assert.assertEquals(AuthProtocolState.UNCHALLENGED, context.getProxyAuthState().getState());
+ Assert.assertEquals(AuthExchange.State.UNCHALLENGED, context.getProxyAuthState().getState());
Assert.assertEquals(null, context.getProxyAuthState().getAuthScheme());
}