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:
parent
e266dae789
commit
1605400e1e
|
@ -163,22 +163,18 @@ 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 getMethod = new HeadMethod(endPointUrl);
|
HttpMethod checkMethod = new HeadMethod(endPointUrl);
|
||||||
getMethod.setFollowRedirects(false);
|
checkMethod.setPath("/ews/services.wsdl");
|
||||||
|
checkMethod.setFollowRedirects(false);
|
||||||
try {
|
try {
|
||||||
int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, getMethod);
|
int 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");
|
||||||
} else if (status != HttpStatus.SC_MOVED_TEMPORARILY) {
|
} else if (status != HttpStatus.SC_OK) {
|
||||||
throw DavGatewayHttpClientFacade.buildHttpException(getMethod);
|
throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status);
|
||||||
}
|
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
getMethod.releaseConnection();
|
checkMethod.releaseConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue