From e8a7e0b7507d14d4c52c2c7d530a659402383cd9 Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 9 Nov 2010 22:36:10 +0000 Subject: [PATCH] EWS: allow autodiscover after authentication failure git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1540 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ews/EwsExchangeSession.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index c0982764..b7929a61 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -148,13 +148,15 @@ public class EwsExchangeSession extends ExchangeSession { // check EWS access try { checkEndPointUrl("/ews/exchange.asmx"); - } catch (DavMailAuthenticationException e) { - throw e; } catch (IOException e) { try { // failover, try to retrieve EWS url from autodiscover checkEndPointUrl(getEwsUrlFromAutoDiscover()); } catch (IOException e2) { + // autodiscover failed and initial exception was authentication failure => throw original exception + if (e instanceof DavMailAuthenticationException) { + throw (DavMailAuthenticationException)e; + } LOGGER.error(e2.getMessage()); throw new DavMailAuthenticationException("EXCEPTION_EWS_NOT_AVAILABLE"); }