"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "httpclient/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java" between
httpcomponents-client-4.5.6-src.tar.gz and httpcomponents-client-4.5.7-src.tar.gz

About: HttpComponents is an Apache project responsible for creating and maintaining a toolset of low level Java components focused on HTTP and associated protocols. Java sources.

HttpAuthenticator.java  (httpcomponents-client-4.5.6-src):HttpAuthenticator.java  (httpcomponents-client-4.5.7-src)
skipping to change at line 82 skipping to change at line 82
final HttpResponse response, final HttpResponse response,
final AuthenticationStrategy authStrategy, final AuthenticationStrategy authStrategy,
final AuthState authState, final AuthState authState,
final HttpContext context) { final HttpContext context) {
if (authStrategy.isAuthenticationRequested(host, response, context)) { if (authStrategy.isAuthenticationRequested(host, response, context)) {
this.log.debug("Authentication required"); this.log.debug("Authentication required");
if (authState.getState() == AuthProtocolState.SUCCESS) { if (authState.getState() == AuthProtocolState.SUCCESS) {
authStrategy.authFailed(host, authState.getAuthScheme(), context ); authStrategy.authFailed(host, authState.getAuthScheme(), context );
} }
return true; return true;
} else {
switch (authState.getState()) {
case CHALLENGED:
case HANDSHAKE:
this.log.debug("Authentication succeeded");
authState.setState(AuthProtocolState.SUCCESS);
authStrategy.authSucceeded(host, authState.getAuthScheme(), cont
ext);
break;
case SUCCESS:
break;
default:
authState.setState(AuthProtocolState.UNCHALLENGED);
}
return false;
} }
switch (authState.getState()) {
case CHALLENGED:
case HANDSHAKE:
this.log.debug("Authentication succeeded");
authState.setState(AuthProtocolState.SUCCESS);
authStrategy.authSucceeded(host, authState.getAuthScheme(), context)
;
break;
case SUCCESS:
break;
default:
authState.setState(AuthProtocolState.UNCHALLENGED);
}
return false;
} }
public boolean handleAuthChallenge( public boolean handleAuthChallenge(
final HttpHost host, final HttpHost host,
final HttpResponse response, final HttpResponse response,
final AuthenticationStrategy authStrategy, final AuthenticationStrategy authStrategy,
final AuthState authState, final AuthState authState,
final HttpContext context) { final HttpContext context) {
try { try {
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
skipping to change at line 144 skipping to change at line 143
final Header challenge = challenges.get(id.toLowerCase(Local e.ROOT)); final Header challenge = challenges.get(id.toLowerCase(Local e.ROOT));
if (challenge != null) { if (challenge != null) {
this.log.debug("Authorization challenge processed"); this.log.debug("Authorization challenge processed");
authScheme.processChallenge(challenge); authScheme.processChallenge(challenge);
if (authScheme.isComplete()) { if (authScheme.isComplete()) {
this.log.debug("Authentication failed"); this.log.debug("Authentication failed");
authStrategy.authFailed(host, authState.getAuthSchem e(), context); authStrategy.authFailed(host, authState.getAuthSchem e(), context);
authState.reset(); authState.reset();
authState.setState(AuthProtocolState.FAILURE); authState.setState(AuthProtocolState.FAILURE);
return false; return false;
} else {
authState.setState(AuthProtocolState.HANDSHAKE);
return true;
} }
} else { authState.setState(AuthProtocolState.HANDSHAKE);
authState.reset(); return true;
// Retry authentication with a different scheme
} }
authState.reset();
// Retry authentication with a different scheme
} }
} }
final Queue<AuthOption> authOptions = authStrategy.select(challenges , host, response, context); final Queue<AuthOption> authOptions = authStrategy.select(challenges , host, response, context);
if (authOptions != null && !authOptions.isEmpty()) { if (authOptions != null && !authOptions.isEmpty()) {
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Selected authentication options: " + authOpt ions); this.log.debug("Selected authentication options: " + authOpt ions);
} }
authState.setState(AuthProtocolState.CHALLENGED); authState.setState(AuthProtocolState.CHALLENGED);
authState.update(authOptions); authState.update(authOptions);
return true; return true;
} else {
return false;
} }
return false;
} catch (final MalformedChallengeException ex) { } catch (final MalformedChallengeException ex) {
if (this.log.isWarnEnabled()) { if (this.log.isWarnEnabled()) {
this.log.warn("Malformed challenge: " + ex.getMessage()); this.log.warn("Malformed challenge: " + ex.getMessage());
} }
authState.reset(); authState.reset();
return false; return false;
} }
} }
public void generateAuthResponse( public void generateAuthResponse(
skipping to change at line 212 skipping to change at line 208
final Header header = doAuth(authScheme, creds, request, context); final Header header = doAuth(authScheme, creds, request, context);
request.addHeader(header); request.addHeader(header);
break; break;
} catch (final AuthenticationException ex) { } catch (final AuthenticationException ex) {
if (this.log.isWarnEnabled()) { if (this.log.isWarnEnabled()) {
this.log.warn(authScheme + " authentication error: " + ex.getMessage()); this.log.warn(authScheme + " authentication error: " + ex.getMessage());
} }
} }
} }
return; return;
} else {
ensureAuthScheme(authScheme);
} }
ensureAuthScheme(authScheme);
} }
if (authScheme != null) { if (authScheme != null) {
try { try {
final Header header = doAuth(authScheme, creds, request, context ); final Header header = doAuth(authScheme, creds, request, context );
request.addHeader(header); request.addHeader(header);
} catch (final AuthenticationException ex) { } catch (final AuthenticationException ex) {
if (this.log.isErrorEnabled()) { if (this.log.isErrorEnabled()) {
this.log.error(authScheme + " authentication error: " + ex.g etMessage()); this.log.error(authScheme + " authentication error: " + ex.g etMessage());
} }
} }
skipping to change at line 238 skipping to change at line 233
private void ensureAuthScheme(final AuthScheme authScheme) { private void ensureAuthScheme(final AuthScheme authScheme) {
Asserts.notNull(authScheme, "Auth scheme"); Asserts.notNull(authScheme, "Auth scheme");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
private Header doAuth( private Header doAuth(
final AuthScheme authScheme, final AuthScheme authScheme,
final Credentials creds, final Credentials creds,
final HttpRequest request, final HttpRequest request,
final HttpContext context) throws AuthenticationException { final HttpContext context) throws AuthenticationException {
if (authScheme instanceof ContextAwareAuthScheme) { return authScheme instanceof ContextAwareAuthScheme
return ((ContextAwareAuthScheme) authScheme).authenticate(creds, req ? ((ContextAwareAuthScheme) authScheme).authenticate(cre
uest, context); ds, request,
} else { context)
return authScheme.authenticate(creds, request); : authScheme.authenticate(creds, request);
}
} }
} }
 End of changes. 10 change blocks. 
31 lines changed or deleted 25 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)