EWS: Avoid /owa form request in direct EWS mode
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2229 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
e9591b72c9
commit
ef80812111
|
@ -207,7 +207,7 @@ public abstract class ExchangeSession {
|
||||||
// manually follow redirect
|
// manually follow redirect
|
||||||
HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url);
|
HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url);
|
||||||
|
|
||||||
if (!this.isAuthenticated()) {
|
if (!this.isAuthenticated(method)) {
|
||||||
if (isBasicAuthentication) {
|
if (isBasicAuthentication) {
|
||||||
int status = method.getStatusCode();
|
int status = method.getStatusCode();
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ public abstract class ExchangeSession {
|
||||||
checkFormLoginQueryString(logonMethod);
|
checkFormLoginQueryString(logonMethod);
|
||||||
|
|
||||||
// workaround for post logon script redirect
|
// workaround for post logon script redirect
|
||||||
if (!isAuthenticated()) {
|
if (!isAuthenticated(logonMethod)) {
|
||||||
// try to get new method from script based redirection
|
// try to get new method from script based redirection
|
||||||
logonMethod = buildLogonMethod(httpClient, logonMethod);
|
logonMethod = buildLogonMethod(httpClient, logonMethod);
|
||||||
|
|
||||||
|
@ -548,7 +548,7 @@ public abstract class ExchangeSession {
|
||||||
logonMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod);
|
logonMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod);
|
||||||
checkFormLoginQueryString(logonMethod);
|
checkFormLoginQueryString(logonMethod);
|
||||||
// also check cookies
|
// also check cookies
|
||||||
if (!isAuthenticated()) {
|
if (!isAuthenticated(logonMethod)) {
|
||||||
throwAuthenticationFailed();
|
throwAuthenticationFailed();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -686,18 +686,25 @@ public abstract class ExchangeSession {
|
||||||
*
|
*
|
||||||
* @return true if session cookies are available
|
* @return true if session cookies are available
|
||||||
*/
|
*/
|
||||||
protected boolean isAuthenticated() {
|
protected boolean isAuthenticated(HttpMethod method) {
|
||||||
boolean authenticated = false;
|
boolean authenticated = false;
|
||||||
for (Cookie cookie : httpClient.getState().getCookies()) {
|
if (method.getStatusCode() == HttpStatus.SC_OK
|
||||||
// Exchange 2003 cookies
|
&& "/ews/services.wsdl".equalsIgnoreCase(method.getPath())) {
|
||||||
if (cookie.getName().startsWith("cadata") || "sessionid".equals(cookie.getName())
|
// direct EWS access returned wsdl
|
||||||
// Exchange 2007 cookie
|
authenticated = true;
|
||||||
|| "UserContext".equals(cookie.getName())
|
} else {
|
||||||
// Direct EWS access
|
// check cookies
|
||||||
|| "exchangecookie".equals(cookie.getName())
|
for (Cookie cookie : httpClient.getState().getCookies()) {
|
||||||
) {
|
// Exchange 2003 cookies
|
||||||
authenticated = true;
|
if (cookie.getName().startsWith("cadata") || "sessionid".equals(cookie.getName())
|
||||||
break;
|
// Exchange 2007 cookie
|
||||||
|
|| "UserContext".equals(cookie.getName())
|
||||||
|
// Direct EWS access
|
||||||
|
|| "exchangecookie".equals(cookie.getName())
|
||||||
|
) {
|
||||||
|
authenticated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return authenticated;
|
return authenticated;
|
||||||
|
|
Loading…
Reference in New Issue