提交 2cca3b07 编写于 作者: W weijun

6586707: NTLM authentication with proxy fails

Reviewed-by: chegar
上级 6fa6bcf1
/*
* Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1995-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1258,6 +1258,11 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
doingNTLMp2ndStage = false;
continue;
}
} else {
inNegotiateProxy = false;
doingNTLMp2ndStage = false;
if (!isUserProxyAuth)
requests.remove("Proxy-Authorization");
}
// cache proxy authentication info
......@@ -1303,7 +1308,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
serverAuthentication.getAuthScheme() != NTLM) {
if (serverAuthentication.isAuthorizationStale (raw)) {
/* we can retry with the current credentials */
disconnectInternal();
disconnectWeb();
redirects++;
requests.set(serverAuthentication.getHeaderName(),
serverAuthentication.getHeaderValue(url, method));
......@@ -1318,7 +1323,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
currentServerCredentials = serverAuthentication;
if (serverAuthentication != null) {
disconnectInternal();
disconnectWeb();
redirects++; // don't let things loop ad nauseum
setCookieHeader();
continue;
......@@ -1327,7 +1332,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
reset ();
/* header not used for ntlm */
if (!serverAuthentication.setHeaders(this, null, raw)) {
disconnectInternal();
disconnectWeb();
throw new IOException ("Authentication failure");
}
doingNTLM2ndStage = false;
......@@ -2319,6 +2324,22 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
connected = false;
}
/**
* Disconnect from the web server at the first 401 error. Do not
* disconnect when using a proxy, a good proxy should have already
* closed the connection to the web server.
*/
private void disconnectWeb() throws IOException {
if (usingProxy()) {
responseCode = -1;
// clean up, particularly, skip the content part
// of a 401 error response
reset();
} else {
disconnectInternal();
}
}
/**
* Disconnect from the server (for internal use)
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册