1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

Experimental: reenable NTLM authentication

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@632 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-07-27 08:55:05 +00:00
parent 8d1446524d
commit 624c969f4d

View File

@ -79,11 +79,20 @@ public final class DavGatewayHttpClientFacade {
httpClient.getParams().setParameter(HttpClientParams.MAX_REDIRECTS, MAX_REDIRECTS);
HostConfiguration hostConfig = httpClient.getHostConfiguration();
hostConfig.setHost(httpURL);
UsernamePasswordCredentials hostCredentials =
new UsernamePasswordCredentials(httpURL.getUser(),
httpURL.getPassword());
httpClient.getState().setCredentials(new AuthScope(httpURL.getHost(), httpURL.getPort(), AuthScope.ANY_REALM),
hostCredentials);
String userName = httpURL.getUser();
String password = httpURL.getPassword();
AuthScope authScope = new AuthScope(httpURL.getHost(), httpURL.getPort(), AuthScope.ANY_REALM);
// detect ntlm authentication (windows domain name in user name)
int backslashindex = userName.indexOf('\\');
if (backslashindex > 0) {
httpClient.getState().setCredentials(authScope,
new NTCredentials(userName.substring(backslashindex + 1),
password, httpURL.getHost(),
userName.substring(0, backslashindex)));
} else {
httpClient.getState().setCredentials(authScope,
new UsernamePasswordCredentials(userName, password));
}
configureClient(httpClient);
return httpClient;
}
@ -96,12 +105,6 @@ public final class DavGatewayHttpClientFacade {
public static void configureClient(HttpClient httpClient) {
httpClient.setHttpConnectionManager(multiThreadedHttpConnectionManager);
ArrayList<String> authPrefs = new ArrayList<String>();
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
// exclude the NTLM authentication scheme
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
boolean enableProxy = Settings.getBooleanProperty("davmail.enableProxy");
String proxyHost = null;
int proxyPort = 0;