From aa08c73a700c875740f170b7c8e5a4f3b68c79e0 Mon Sep 17 00:00:00 2001 From: mguessan Date: Fri, 10 Jan 2014 18:15:26 +0000 Subject: [PATCH] New failover call in checkEndPointUrl git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2208 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../davmail/exchange/ews/EwsExchangeSession.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index c1858c9e..10cd9fac 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -169,7 +169,17 @@ public class EwsExchangeSession extends ExchangeSession { try { int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); if (status == HttpStatus.SC_UNAUTHORIZED) { - throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); + // retry with /ews/exchange.asmx + checkMethod.releaseConnection(); + checkMethod = new HeadMethod(endPointUrl); + checkMethod.setFollowRedirects(true); + status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); + if (status == HttpStatus.SC_UNAUTHORIZED) { + throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); + } else if (status != HttpStatus.SC_OK) { + throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status); + } + } else if (status != HttpStatus.SC_OK) { throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status); }