mirror of
https://github.com/moparisthebest/davmail
synced 2024-08-13 16:53:51 -04:00
Improve NTLM authentication detection
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1593 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
ef7cfae687
commit
76ecd3d00b
@ -269,6 +269,18 @@ public final class DavGatewayHttpClientFacade {
|
||||
return executeFollowRedirects(httpClient, method);
|
||||
}
|
||||
|
||||
private static int checkNTLM(HttpClient httpClient, HttpMethod currentMethod) throws IOException {
|
||||
int status = currentMethod.getStatusCode();
|
||||
if ((status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
|
||||
&& acceptsNTLMOnly(currentMethod) && !hasNTLM(httpClient)) {
|
||||
LOGGER.debug("Received " + status + " unauthorized at " + currentMethod.getURI() + ", retrying with NTLM");
|
||||
resetMethod(currentMethod);
|
||||
addNTLM(httpClient);
|
||||
status = httpClient.executeMethod(currentMethod);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute method with httpClient, follow 30x redirects.
|
||||
*
|
||||
@ -281,15 +293,9 @@ public final class DavGatewayHttpClientFacade {
|
||||
HttpMethod currentMethod = method;
|
||||
try {
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_EXECUTE_FOLLOW_REDIRECTS", currentMethod.getURI()));
|
||||
int status = httpClient.executeMethod(currentMethod);
|
||||
// check NTLM
|
||||
if ((status == HttpStatus.SC_UNAUTHORIZED || status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED)
|
||||
&& acceptsNTLMOnly(method) && !hasNTLM(httpClient)) {
|
||||
LOGGER.debug("Received " + status + " unauthorized at " + currentMethod.getURI() + ", retrying with NTLM");
|
||||
resetMethod(currentMethod);
|
||||
addNTLM(httpClient);
|
||||
status = httpClient.executeMethod(currentMethod);
|
||||
}
|
||||
httpClient.executeMethod(currentMethod);
|
||||
int status = checkNTLM(httpClient, currentMethod);
|
||||
|
||||
Header location = currentMethod.getResponseHeader("Location");
|
||||
int redirectCount = 0;
|
||||
while (redirectCount++ < 10
|
||||
@ -309,6 +315,7 @@ public final class DavGatewayHttpClientFacade {
|
||||
currentMethod.setFollowRedirects(false);
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_EXECUTE_FOLLOW_REDIRECTS_COUNT", currentMethod.getURI(), redirectCount));
|
||||
httpClient.executeMethod(currentMethod);
|
||||
checkNTLM(httpClient, currentMethod);
|
||||
location = currentMethod.getResponseHeader("Location");
|
||||
}
|
||||
if (location != null && isRedirect(currentMethod.getStatusCode())) {
|
||||
|
Loading…
Reference in New Issue
Block a user