Commit d97e03e3 authored by Mickaël Guessant's avatar Mickaël Guessant

EWS: update checkEndPointUrl, send get root folder request instead of static...

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

git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@2333 3d1905a2-6b24-0410-a738-b14d5a86fcbd
parent d5d5f761
......@@ -172,16 +172,13 @@ public class EwsExchangeSession extends ExchangeSession {
* @throws IOException on error
*/
protected void checkEndPointUrl(String endPointUrl) throws IOException {
HttpMethod checkMethod = new GetMethod(endPointUrl);
checkMethod.setPath("/ews/services.wsdl");
checkMethod.setFollowRedirects(false);
GetFolderMethod checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null);
try {
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) {
// retry with /ews/exchange.asmx
checkMethod.releaseConnection();
checkMethod = new GetMethod(endPointUrl);
checkMethod.setFollowRedirects(true);
checkMethod = new GetFolderMethod(BaseShape.ID_ONLY, DistinguishedFolderId.getInstance(null, DistinguishedFolderId.Name.root), null);
status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) {
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
......@@ -203,7 +200,9 @@ public class EwsExchangeSession extends ExchangeSession {
if (method != null) {
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
if (!directEws) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment