EWS: update checkEndPointUrl, send get root folder request instead of static wsdl request no longer available on Office365

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2333 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2015-02-12 15:31:43 +00:00
parent cbec33e726
commit b0ea531d3a
1 changed files with 5 additions and 6 deletions

View File

@ -172,16 +172,13 @@ public class EwsExchangeSession extends ExchangeSession {
* @throws IOException on error * @throws IOException on error
*/ */
protected void checkEndPointUrl(String endPointUrl) throws IOException { protected void checkEndPointUrl(String endPointUrl) throws IOException {
HttpMethod checkMethod = new GetMethod(endPointUrl); GetFolderMethod checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null);
checkMethod.setPath("/ews/services.wsdl");
checkMethod.setFollowRedirects(false);
try { try {
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) { if (status == HttpStatus.SC_UNAUTHORIZED) {
// retry with /ews/exchange.asmx // retry with /ews/exchange.asmx
checkMethod.releaseConnection(); checkMethod.releaseConnection();
checkMethod = new GetMethod(endPointUrl); checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null);
checkMethod.setFollowRedirects(true);
status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) { if (status == HttpStatus.SC_UNAUTHORIZED) {
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
@ -203,7 +200,9 @@ public class EwsExchangeSession extends ExchangeSession {
if (method != null) { if (method != null) {
method.releaseConnection(); method.releaseConnection();
} }
directEws = method == null || "/ews/services.wsdl".equalsIgnoreCase(method.getPath()); directEws = method == null
|| "/ews/services.wsdl".equalsIgnoreCase(method.getPath())
|| "/ews/exchange.asmx".equalsIgnoreCase(method.getPath());
// options page is not available in direct EWS mode // options page is not available in direct EWS mode
if (!directEws) { if (!directEws) {