Renamed AuthChallengeState to AuthProtocolState

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1176369 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-09-27 13:05:46 +00:00
parent e4ea515f20
commit c514ac2a4c
8 changed files with 35 additions and 35 deletions

View File

@ -26,7 +26,7 @@
package org.apache.http.auth; package org.apache.http.auth;
public enum AuthChallengeState { public enum AuthProtocolState {
UNCHALLENGED, CHALLENGED, FAILURE, SUCCESS UNCHALLENGED, CHALLENGED, FAILURE, SUCCESS

View File

@ -37,8 +37,8 @@ import org.apache.http.annotation.NotThreadSafe;
@NotThreadSafe @NotThreadSafe
public class AuthState { public class AuthState {
/** Actual state of authentication process */ /** Actual state of authentication protocol */
private AuthChallengeState challengeState; private AuthProtocolState state;
/** Actual authentication scheme */ /** Actual authentication scheme */
private AuthScheme authScheme; private AuthScheme authScheme;
@ -55,14 +55,14 @@ public class AuthState {
*/ */
public AuthState() { public AuthState() {
super(); super();
this.challengeState = AuthChallengeState.UNCHALLENGED; this.state = AuthProtocolState.UNCHALLENGED;
} }
/** /**
* Invalidates the authentication state by resetting its parameters. * Invalidates the authentication state by resetting its parameters.
*/ */
public void invalidate() { public void invalidate() {
this.challengeState = AuthChallengeState.UNCHALLENGED; this.state = AuthProtocolState.UNCHALLENGED;
this.authScheme = null; this.authScheme = null;
this.authScope = null; this.authScope = null;
this.credentials = null; this.credentials = null;
@ -98,15 +98,15 @@ public class AuthState {
/** /**
* @since 4.2 * @since 4.2
*/ */
public AuthChallengeState getChallengeState() { public AuthProtocolState getState() {
return this.challengeState; return this.state;
} }
/** /**
* @since 4.2 * @since 4.2
*/ */
public void setChallengeState(final AuthChallengeState state) { public void setState(final AuthProtocolState state) {
this.challengeState = state != null ? state : AuthChallengeState.UNCHALLENGED; this.state = state != null ? state : AuthProtocolState.UNCHALLENGED;
} }
/** /**
@ -154,7 +154,7 @@ public class AuthState {
@Override @Override
public String toString() { public String toString() {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
buffer.append("state:").append(this.challengeState).append(";"); buffer.append("state:").append(this.state).append(";");
if (this.authScheme != null) { if (this.authScheme != null) {
buffer.append("auth scheme:").append(this.authScheme.getSchemeName()).append(";"); buffer.append("auth scheme:").append(this.authScheme.getSchemeName()).append(";");
} }

View File

@ -88,7 +88,7 @@ public class ResponseAuthCache implements HttpResponseInterceptor {
authCache = new BasicAuthCache(); authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache); context.setAttribute(ClientContext.AUTH_CACHE, authCache);
} }
switch (targetState.getChallengeState()) { switch (targetState.getState()) {
case CHALLENGED: case CHALLENGED:
cache(authCache, target, targetState.getAuthScheme()); cache(authCache, target, targetState.getAuthScheme());
break; break;
@ -106,7 +106,7 @@ public class ResponseAuthCache implements HttpResponseInterceptor {
authCache = new BasicAuthCache(); authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache); context.setAttribute(ClientContext.AUTH_CACHE, authCache);
} }
switch (proxyState.getChallengeState()) { switch (proxyState.getState()) {
case CHALLENGED: case CHALLENGED:
cache(authCache, proxy, proxyState.getAuthScheme()); cache(authCache, proxy, proxyState.getAuthScheme());
break; break;

View File

@ -45,7 +45,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException; import org.apache.http.ProtocolException;
import org.apache.http.ProtocolVersion; import org.apache.http.ProtocolVersion;
import org.apache.http.annotation.NotThreadSafe; import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AuthChallengeState; import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState; import org.apache.http.auth.AuthState;
import org.apache.http.client.AuthenticationHandler; import org.apache.http.client.AuthenticationHandler;
@ -1069,8 +1069,8 @@ public class DefaultRequestDirector implements RequestDirector {
uri.getScheme()); uri.getScheme());
// Unset auth scope // Unset auth scope
targetAuthState.setChallengeState(AuthChallengeState.UNCHALLENGED); targetAuthState.setState(AuthProtocolState.UNCHALLENGED);
proxyAuthState.setChallengeState(AuthChallengeState.UNCHALLENGED); proxyAuthState.setState(AuthProtocolState.UNCHALLENGED);
// Invalidate auth states if redirecting to another host // Invalidate auth states if redirecting to another host
if (!route.getTargetHost().equals(newTarget)) { if (!route.getTargetHost().equals(newTarget)) {

View File

@ -35,7 +35,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.http.Header; import org.apache.http.Header;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthChallengeState; import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthOption; import org.apache.http.auth.AuthOption;
import org.apache.http.auth.AuthScheme; import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState; import org.apache.http.auth.AuthState;
@ -64,10 +64,10 @@ public class HttpAuthenticator {
if (authStrategy.isAuthenticationRequested(response, context)) { if (authStrategy.isAuthenticationRequested(response, context)) {
return true; return true;
} else { } else {
if (authState.getChallengeState() == AuthChallengeState.CHALLENGED) { if (authState.getState() == AuthProtocolState.CHALLENGED) {
authState.setChallengeState(AuthChallengeState.SUCCESS); authState.setState(AuthProtocolState.SUCCESS);
} else { } else {
authState.setChallengeState(AuthChallengeState.UNCHALLENGED); authState.setState(AuthProtocolState.UNCHALLENGED);
} }
return false; return false;
} }
@ -97,11 +97,11 @@ public class HttpAuthenticator {
authScheme.processChallenge(challenge); authScheme.processChallenge(challenge);
if (authScheme.isComplete()) { if (authScheme.isComplete()) {
this.log.debug("Authentication failed"); this.log.debug("Authentication failed");
authState.setChallengeState(AuthChallengeState.FAILURE); authState.setState(AuthProtocolState.FAILURE);
authState.setCredentials(null); authState.setCredentials(null);
return false; return false;
} else { } else {
authState.setChallengeState(AuthChallengeState.CHALLENGED); authState.setState(AuthProtocolState.CHALLENGED);
return true; return true;
} }
} else { } else {
@ -115,7 +115,7 @@ public class HttpAuthenticator {
} }
authState.setAuthScheme(authOption.getAuthScheme()); authState.setAuthScheme(authOption.getAuthScheme());
authState.setCredentials(authOption.getCredentials()); authState.setCredentials(authOption.getCredentials());
authState.setChallengeState(AuthChallengeState.CHALLENGED); authState.setState(AuthProtocolState.CHALLENGED);
return true; return true;
} catch (MalformedChallengeException ex) { } catch (MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) { if (this.log.isWarnEnabled()) {

View File

@ -33,7 +33,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpRequestInterceptor;
import org.apache.http.auth.AUTH; import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthChallengeState; import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthState; import org.apache.http.auth.AuthState;
import org.apache.http.auth.Credentials; import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.auth.UsernamePasswordCredentials;
@ -271,7 +271,7 @@ public class TestRequestProxyAuthentication {
authstate.setAuthScheme(authscheme); authstate.setAuthScheme(authscheme);
authstate.setCredentials(creds); authstate.setCredentials(creds);
authstate.setChallengeState(AuthChallengeState.UNCHALLENGED); authstate.setState(AuthProtocolState.UNCHALLENGED);
context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn); context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate); context.setAttribute(ClientContext.PROXY_AUTH_STATE, authstate);

View File

@ -32,7 +32,7 @@ import org.apache.http.Header;
import org.apache.http.HttpRequest; import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpRequestInterceptor;
import org.apache.http.auth.AUTH; import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthChallengeState; import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthState; import org.apache.http.auth.AuthState;
import org.apache.http.auth.Credentials; import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.auth.UsernamePasswordCredentials;
@ -201,7 +201,7 @@ public class TestRequestTargetAuthentication {
authstate.setAuthScheme(authscheme); authstate.setAuthScheme(authscheme);
authstate.setCredentials(creds); authstate.setCredentials(creds);
authstate.setChallengeState(AuthChallengeState.UNCHALLENGED); authstate.setState(AuthProtocolState.UNCHALLENGED);
context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate); context.setAttribute(ClientContext.TARGET_AUTH_STATE, authstate);

View File

@ -33,7 +33,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor; import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpVersion; import org.apache.http.HttpVersion;
import org.apache.http.auth.AUTH; import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthChallengeState; import org.apache.http.auth.AuthProtocolState;
import org.apache.http.auth.AuthState; import org.apache.http.auth.AuthState;
import org.apache.http.client.AuthCache; import org.apache.http.client.AuthCache;
import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.auth.BasicScheme;
@ -90,10 +90,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge( this.authscheme2.processChallenge(
new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm")); new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
this.targetState.setChallengeState(AuthChallengeState.CHALLENGED); this.targetState.setState(AuthProtocolState.CHALLENGED);
this.targetState.setAuthScheme(this.authscheme1); this.targetState.setAuthScheme(this.authscheme1);
this.proxyState.setChallengeState(AuthChallengeState.CHALLENGED); this.proxyState.setState(AuthProtocolState.CHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2); this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext(); HttpContext context = new BasicHttpContext();
@ -147,10 +147,10 @@ public class TestResponseAuthCache {
public void testAuthSchemeNotCompleted() throws Exception { public void testAuthSchemeNotCompleted() throws Exception {
HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
this.targetState.setChallengeState(AuthChallengeState.CHALLENGED); this.targetState.setState(AuthProtocolState.CHALLENGED);
this.targetState.setAuthScheme(this.authscheme1); this.targetState.setAuthScheme(this.authscheme1);
this.proxyState.setChallengeState(AuthChallengeState.CHALLENGED); this.proxyState.setState(AuthProtocolState.CHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2); this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext(); HttpContext context = new BasicHttpContext();
@ -175,10 +175,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge( this.authscheme2.processChallenge(
new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm")); new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
this.targetState.setChallengeState(AuthChallengeState.UNCHALLENGED); this.targetState.setState(AuthProtocolState.UNCHALLENGED);
this.targetState.setAuthScheme(this.authscheme1); this.targetState.setAuthScheme(this.authscheme1);
this.proxyState.setChallengeState(AuthChallengeState.UNCHALLENGED); this.proxyState.setState(AuthProtocolState.UNCHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2); this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext(); HttpContext context = new BasicHttpContext();
@ -205,10 +205,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge( this.authscheme2.processChallenge(
new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm")); new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm=auth-realm"));
this.targetState.setChallengeState(AuthChallengeState.FAILURE); this.targetState.setState(AuthProtocolState.FAILURE);
this.targetState.setAuthScheme(this.authscheme1); this.targetState.setAuthScheme(this.authscheme1);
this.proxyState.setChallengeState(AuthChallengeState.FAILURE); this.proxyState.setState(AuthProtocolState.FAILURE);
this.proxyState.setAuthScheme(this.authscheme2); this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext(); HttpContext context = new BasicHttpContext();