1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-21 06:58:51 -05:00

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

View File

@ -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) {