HTTPCLIENT-1087: NTLM proxy authentication fails on retry if the underlying connection is closed as a result of a target authentication failure

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1104207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2011-05-17 12:54:14 +00:00
parent 195026ce43
commit e2fa3ae38f
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,9 @@
Changes since 4.1.1 Changes since 4.1.1
* [HTTPCLIENT-1087] NTLM proxy authentication fails on retry if the underlying connection is closed
as a result of a target authentication failure.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-1079] Fixed Kerberos cross-realm support * [HTTPCLIENT-1079] Fixed Kerberos cross-realm support
Contributed by Michael Osipov <1983-01-06 at gmx.net> Contributed by Michael Osipov <1983-01-06 at gmx.net>

View File

@ -492,6 +492,8 @@ public class DefaultRequestDirector implements RequestDirector {
managedConn.markReusable(); managedConn.markReusable();
} else { } else {
managedConn.close(); managedConn.close();
invalidateAuthIfSuccessful(this.proxyAuthState);
invalidateAuthIfSuccessful(this.targetAuthState);
} }
// check if we can use the same connection for the followup // check if we can use the same connection for the followup
if (!followup.getRoute().equals(roureq.getRoute())) { if (!followup.getRoute().equals(roureq.getRoute())) {
@ -1232,4 +1234,14 @@ public class DefaultRequestDirector implements RequestDirector {
authState.setCredentials(creds); authState.setCredentials(creds);
} }
private void invalidateAuthIfSuccessful(final AuthState authState) {
AuthScheme authscheme = authState.getAuthScheme();
if (authscheme != null
&& authscheme.isConnectionBased()
&& authscheme.isComplete()
&& authState.getCredentials() != null) {
authState.invalidate();
}
}
} // class DefaultClientRequestDirector } // class DefaultClientRequestDirector