1
0
mirror of https://github.com/moparisthebest/davmail synced 2025-01-05 18:58:02 -05:00

fix 2995990: Add support for already authenticated users

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1382 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-08-24 21:44:01 +00:00
parent bd6bf0b395
commit e06427d4e8

View File

@ -155,18 +155,20 @@ public abstract class ExchangeSession {
// manually follow redirect // manually follow redirect
HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url); HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url);
if (isBasicAuthentication) { if (!this.isAuthenticated()) {
int status = method.getStatusCode(); if (isBasicAuthentication) {
int status = method.getStatusCode();
if (status == HttpStatus.SC_UNAUTHORIZED) { if (status == HttpStatus.SC_UNAUTHORIZED) {
method.releaseConnection(); method.releaseConnection();
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
} else if (status != HttpStatus.SC_OK) { } else if (status != HttpStatus.SC_OK) {
method.releaseConnection(); method.releaseConnection();
throw DavGatewayHttpClientFacade.buildHttpException(method); throw DavGatewayHttpClientFacade.buildHttpException(method);
}
} else {
method = formLogin(httpClient, method, userName, password);
} }
} else {
method = formLogin(httpClient, method, userName, password);
} }
// avoid 401 roundtrips, only if NTLM is disabled // avoid 401 roundtrips, only if NTLM is disabled
@ -422,7 +424,7 @@ public abstract class ExchangeSession {
HttpMethod logonMethod = buildLogonMethod(httpClient, initmethod); HttpMethod logonMethod = buildLogonMethod(httpClient, initmethod);
if (logonMethod == null) { if (logonMethod == null) {
LOGGER.debug("Authentication form not found at " + initmethod.getURI()+ ", trying default url"); LOGGER.debug("Authentication form not found at " + initmethod.getURI() + ", trying default url");
logonMethod = new PostMethod("/owa/auth/owaauth.dll"); logonMethod = new PostMethod("/owa/auth/owaauth.dll");
} }
@ -1976,7 +1978,7 @@ public abstract class ExchangeSession {
} }
protected HttpException buildHttpException(Exception e) { protected HttpException buildHttpException(Exception e) {
String message = "Unable to get event " + getName() + " subject: "+subject+" at " + permanentUrl + ": " + e.getMessage(); String message = "Unable to get event " + getName() + " subject: " + subject + " at " + permanentUrl + ": " + e.getMessage();
LOGGER.warn(message); LOGGER.warn(message);
return new HttpException(message); return new HttpException(message);
} }