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
1 changed files with 14 additions and 12 deletions

View File

@ -155,18 +155,20 @@ public abstract class ExchangeSession {
// manually follow redirect
HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url);
if (isBasicAuthentication) {
int status = method.getStatusCode();
if (!this.isAuthenticated()) {
if (isBasicAuthentication) {
int status = method.getStatusCode();
if (status == HttpStatus.SC_UNAUTHORIZED) {
method.releaseConnection();
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
} else if (status != HttpStatus.SC_OK) {
method.releaseConnection();
throw DavGatewayHttpClientFacade.buildHttpException(method);
if (status == HttpStatus.SC_UNAUTHORIZED) {
method.releaseConnection();
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
} else if (status != HttpStatus.SC_OK) {
method.releaseConnection();
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
@ -422,7 +424,7 @@ public abstract class ExchangeSession {
HttpMethod logonMethod = buildLogonMethod(httpClient, initmethod);
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");
}
@ -1976,7 +1978,7 @@ public abstract class ExchangeSession {
}
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);
return new HttpException(message);
}