From 5dc1d9da7e56526776ebdea6fe8fb41b70df722b Mon Sep 17 00:00:00 2001 From: michaelm Date: Mon, 20 Oct 2014 10:29:30 +0100 Subject: [PATCH] 8048035: Ensure proper proxy protocols Reviewed-by: chegar, coffeys --- .../net/www/protocol/http/HttpURLConnection.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 7e02ea496..31fdad864 100644 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -336,6 +336,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection { /* try auth without calling Authenticator. Used for transparent NTLM authentication */ private boolean tryTransparentNTLMServer = true; private boolean tryTransparentNTLMProxy = true; + private boolean useProxyResponseCode = false; /* Used by Windows specific code */ private Object authObj; @@ -2243,6 +2244,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection { if (tryTransparentNTLMProxy) { tryTransparentNTLMProxy = NTLMAuthenticationProxy.supportsTransparentAuth; + /* If the platform supports transparent authentication + * then normally it's ok to do transparent auth to a proxy + * because we generally trust proxies (chosen by the user) + * But not in the case of 305 response where the server + * chose it. */ + if (tryTransparentNTLMProxy && useProxyResponseCode) { + tryTransparentNTLMProxy = false; + } } a = null; if (tryTransparentNTLMProxy) { @@ -2614,6 +2623,10 @@ public class HttpURLConnection extends java.net.HttpURLConnection { requests.set(0, method + " " + getRequestURI()+" " + httpVersion, null); connected = true; + // need to remember this in case NTLM proxy authentication gets + // used. We can't use transparent authentication when user + // doesn't know about proxy. + useProxyResponseCode = true; } else { // maintain previous headers, just change the name // of the file we're getting -- GitLab