1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-14 11:42:23 -05:00

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
This commit is contained in:
mguessan 2009-11-16 21:54:16 +00:00
parent 209adc2b5d
commit 38a39dbaa4

View File

@ -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,