EWS: Fix regression in checkEndPointUrl, get /ews/services.wsdl

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2117 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2013-05-14 08:25:37 +00:00
parent e266dae789
commit 1605400e1e
1 changed files with 7 additions and 11 deletions

View File

@ -163,22 +163,18 @@ public class EwsExchangeSession extends ExchangeSession {
* @throws IOException on error
*/
protected void checkEndPointUrl(String endPointUrl) throws IOException {
HttpMethod getMethod = new HeadMethod(endPointUrl);
getMethod.setFollowRedirects(false);
HttpMethod checkMethod = new HeadMethod(endPointUrl);
checkMethod.setPath("/ews/services.wsdl");
checkMethod.setFollowRedirects(false);
try {
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, getMethod);
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod);
if (status == HttpStatus.SC_UNAUTHORIZED) {
throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED");
} else if (status != HttpStatus.SC_MOVED_TEMPORARILY) {
throw DavGatewayHttpClientFacade.buildHttpException(getMethod);
}
// check Location
Header locationHeader = getMethod.getResponseHeader("Location");
if (locationHeader == null || !"/ews/services.wsdl".equalsIgnoreCase(locationHeader.getValue())) {
throw new IOException("Ews endpoint not available at " + getMethod.getURI().toString());
} else if (status != HttpStatus.SC_OK) {
throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status);
}
} finally {
getMethod.releaseConnection();
checkMethod.releaseConnection();
}
}