From 38a39dbaa4adaa3f52bd02be787484137334f085 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 16 Nov 2009 21:54:16 +0000 Subject: [PATCH] Host is mandatory for NTLMScheme, get current hostname for proxy authentication git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@838 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/http/DavGatewayHttpClientFacade.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/java/davmail/http/DavGatewayHttpClientFacade.java b/src/java/davmail/http/DavGatewayHttpClientFacade.java index 4e083fa8..5e6e2418 100644 --- a/src/java/davmail/http/DavGatewayHttpClientFacade.java +++ b/src/java/davmail/http/DavGatewayHttpClientFacade.java @@ -41,6 +41,8 @@ import org.apache.log4j.Logger; import java.io.IOException; import java.util.ArrayList; +import java.net.InetAddress; +import java.net.UnknownHostException; /** * Create HttpClient instance according to DavGateway Settings @@ -146,9 +148,16 @@ public final class DavGatewayHttpClientFacade { // detect ntlm authentication (windows domain name in user name) int backslashindex = proxyUser.indexOf('\\'); if (backslashindex > 0) { + // get local host name for NTLM authentication + String host; + try { + host = InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException e) { + host = "localhost"; + } httpClient.getState().setProxyCredentials(authScope, new NTCredentials(proxyUser.substring(backslashindex + 1), - proxyPassword, null, + proxyPassword, host, proxyUser.substring(0, backslashindex))); } else { httpClient.getState().setProxyCredentials(authScope,