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;
public enum AuthChallengeState {
public enum AuthProtocolState {
UNCHALLENGED, CHALLENGED, FAILURE, SUCCESS

View File

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

View File

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

View File

@ -45,7 +45,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.ProtocolException;
import org.apache.http.ProtocolVersion;
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.AuthState;
import org.apache.http.client.AuthenticationHandler;
@ -1069,8 +1069,8 @@ public class DefaultRequestDirector implements RequestDirector {
uri.getScheme());
// Unset auth scope
targetAuthState.setChallengeState(AuthChallengeState.UNCHALLENGED);
proxyAuthState.setChallengeState(AuthChallengeState.UNCHALLENGED);
targetAuthState.setState(AuthProtocolState.UNCHALLENGED);
proxyAuthState.setState(AuthProtocolState.UNCHALLENGED);
// Invalidate auth states if redirecting to another host
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.HttpHost;
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.AuthScheme;
import org.apache.http.auth.AuthState;
@ -64,10 +64,10 @@ public class HttpAuthenticator {
if (authStrategy.isAuthenticationRequested(response, context)) {
return true;
} else {
if (authState.getChallengeState() == AuthChallengeState.CHALLENGED) {
authState.setChallengeState(AuthChallengeState.SUCCESS);
if (authState.getState() == AuthProtocolState.CHALLENGED) {
authState.setState(AuthProtocolState.SUCCESS);
} else {
authState.setChallengeState(AuthChallengeState.UNCHALLENGED);
authState.setState(AuthProtocolState.UNCHALLENGED);
}
return false;
}
@ -97,11 +97,11 @@ public class HttpAuthenticator {
authScheme.processChallenge(challenge);
if (authScheme.isComplete()) {
this.log.debug("Authentication failed");
authState.setChallengeState(AuthChallengeState.FAILURE);
authState.setState(AuthProtocolState.FAILURE);
authState.setCredentials(null);
return false;
} else {
authState.setChallengeState(AuthChallengeState.CHALLENGED);
authState.setState(AuthProtocolState.CHALLENGED);
return true;
}
} else {
@ -115,7 +115,7 @@ public class HttpAuthenticator {
}
authState.setAuthScheme(authOption.getAuthScheme());
authState.setCredentials(authOption.getCredentials());
authState.setChallengeState(AuthChallengeState.CHALLENGED);
authState.setState(AuthProtocolState.CHALLENGED);
return true;
} catch (MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) {

View File

@ -33,7 +33,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
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.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
@ -271,7 +271,7 @@ public class TestRequestProxyAuthentication {
authstate.setAuthScheme(authscheme);
authstate.setCredentials(creds);
authstate.setChallengeState(AuthChallengeState.UNCHALLENGED);
authstate.setState(AuthProtocolState.UNCHALLENGED);
context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
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.HttpRequestInterceptor;
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.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
@ -201,7 +201,7 @@ public class TestRequestTargetAuthentication {
authstate.setAuthScheme(authscheme);
authstate.setCredentials(creds);
authstate.setChallengeState(AuthChallengeState.UNCHALLENGED);
authstate.setState(AuthProtocolState.UNCHALLENGED);
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.HttpVersion;
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.client.AuthCache;
import org.apache.http.impl.auth.BasicScheme;
@ -90,10 +90,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge(
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.proxyState.setChallengeState(AuthChallengeState.CHALLENGED);
this.proxyState.setState(AuthProtocolState.CHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext();
@ -147,10 +147,10 @@ public class TestResponseAuthCache {
public void testAuthSchemeNotCompleted() throws Exception {
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.proxyState.setChallengeState(AuthChallengeState.CHALLENGED);
this.proxyState.setState(AuthProtocolState.CHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext();
@ -175,10 +175,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge(
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.proxyState.setChallengeState(AuthChallengeState.UNCHALLENGED);
this.proxyState.setState(AuthProtocolState.UNCHALLENGED);
this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext();
@ -205,10 +205,10 @@ public class TestResponseAuthCache {
this.authscheme2.processChallenge(
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.proxyState.setChallengeState(AuthChallengeState.FAILURE);
this.proxyState.setState(AuthProtocolState.FAILURE);
this.proxyState.setAuthScheme(this.authscheme2);
HttpContext context = new BasicHttpContext();