From a2a581eba12889f9b5a7ad36e698f3c3c5188bc6 Mon Sep 17 00:00:00 2001 From: Karl Wright Date: Fri, 17 Mar 2017 16:04:02 +0000 Subject: [PATCH] Fix for HTTPCLIENT-1833 git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1787433 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE_NOTES.txt | 3 +++ .../http/impl/auth/win/WindowsNegotiateScheme.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 0e2ae4e93..95ceac3cd 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -8,6 +8,9 @@ Please note that as of 4.4 HttpClient requires Java 1.6 or newer. Changelog: ------------------- +* [HTTPCLIENT-1833] Fix Windows Negotiate-NTLM handling of proxies. + Contributed by Roman Stoffel + * [HTTPCLIENT-1817] Add a "Trust All" TrustStrategy implementation. Contributed by Gary Gregory diff --git a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java index 7e8b86612..b07c75ec5 100644 --- a/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java +++ b/httpclient-win/src/main/java/org/apache/http/impl/auth/win/WindowsNegotiateScheme.java @@ -241,10 +241,18 @@ public class WindowsNegotiateScheme extends AuthSchemeBase { final String spn; if (this.servicePrincipalName != null) { spn = this.servicePrincipalName; + } else if(isProxy()){ + final HttpClientContext clientContext = HttpClientContext.adapt(context); + final RouteInfo route = clientContext.getHttpRoute(); + if (route != null) { + spn = "HTTP/" + route.getProxyHost().getHostName(); + } else { + // Should not happen + spn = null; + } } else { final HttpClientContext clientContext = HttpClientContext.adapt(context); - final HttpHost target = clientContext.getTargetHost(); - if (target != null) { + final HttpHost target = clientContext.getTargetHost(); if (target != null) { spn = "HTTP/" + target.getHostName(); } else { final RouteInfo route = clientContext.getHttpRoute();