1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-02-28 09:21:49 -05:00

Fix regression in 3.6.3: basic authentication broken in checkConfig

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@943 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-02-12 10:23:07 +00:00
parent 58eddd24f7
commit a4090a230b
2 changed files with 26 additions and 3 deletions

View File

@ -178,11 +178,10 @@ public final class ExchangeSessionFactory {
GetMethod testMethod = new GetMethod(url);
try {
// get webMail root url (will not follow redirects)
testMethod.setDoAuthentication(false);
int status = DavGatewayHttpClientFacade.executeGetMethod(httpClient, testMethod, false);
int status = DavGatewayHttpClientFacade.executeTestMethod(httpClient, testMethod);
ExchangeSession.LOGGER.debug("Test configuration status: " + status);
if (status != HttpStatus.SC_OK && status != HttpStatus.SC_UNAUTHORIZED
&& status != HttpStatus.SC_MOVED_TEMPORARILY && status != HttpStatus.SC_MOVED_PERMANENTLY) {
&& !DavGatewayHttpClientFacade.isRedirect(status)) {
throw new DavMailException("EXCEPTION_CONNECTION_FAILED", url, status);
}
// session opened, future failure will mean network down

View File

@ -413,6 +413,30 @@ public final class DavGatewayHttpClientFacade {
}
}
/**
* Execute test method from checkConfig, with proxy credentials, but without Exchange credentials.
*
* @param httpClient Http client instance
* @param method Http method
* @param followRedirects Follow redirects flag
* @return Http status
* @throws IOException on error
*/
public static int executeTestMethod(HttpClient httpClient, GetMethod method) throws IOException {
// do not follow redirects in expired sessions
method.setFollowRedirects(false);
int status = httpClient.executeMethod(method);
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED
&& acceptsNTLMOnly(method) && !hasNTLM(httpClient)) {
method.releaseConnection();
LOGGER.debug("Received " + status + " unauthorized at " + method.getURI() + ", retrying with NTLM");
addNTLM(httpClient);
status = httpClient.executeMethod(method);
}
return status;
}
/**
* Execute Get method, do not follow redirects.
*