mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-04 14:52:24 -05:00
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
|
||||
HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, url);
|
||||
|
||||
if (!this.isAuthenticated()) {
|
||||
if (!this.isAuthenticated(method)) {
|
||||
if (isBasicAuthentication) {
|
||||
int status = method.getStatusCode();
|
||||
|
||||
@ -531,7 +531,7 @@ public abstract class ExchangeSession {
|
||||
checkFormLoginQueryString(logonMethod);
|
||||
|
||||
// workaround for post logon script redirect
|
||||
if (!isAuthenticated()) {
|
||||
if (!isAuthenticated(logonMethod)) {
|
||||
// try to get new method from script based redirection
|
||||
logonMethod = buildLogonMethod(httpClient, logonMethod);
|
||||
|
||||
@ -548,7 +548,7 @@ public abstract class ExchangeSession {
|
||||
logonMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod);
|
||||
checkFormLoginQueryString(logonMethod);
|
||||
// also check cookies
|
||||
if (!isAuthenticated()) {
|
||||
if (!isAuthenticated(logonMethod)) {
|
||||
throwAuthenticationFailed();
|
||||
}
|
||||
} else {
|
||||
@ -686,18 +686,25 @@ public abstract class ExchangeSession {
|
||||
*
|
||||
* @return true if session cookies are available
|
||||
*/
|
||||
protected boolean isAuthenticated() {
|
||||
protected boolean isAuthenticated(HttpMethod method) {
|
||||
boolean authenticated = false;
|
||||
for (Cookie cookie : httpClient.getState().getCookies()) {
|
||||
// Exchange 2003 cookies
|
||||
if (cookie.getName().startsWith("cadata") || "sessionid".equals(cookie.getName())
|
||||
// Exchange 2007 cookie
|
||||
|| "UserContext".equals(cookie.getName())
|
||||
// Direct EWS access
|
||||
|| "exchangecookie".equals(cookie.getName())
|
||||
) {
|
||||
authenticated = true;
|
||||
break;
|
||||
if (method.getStatusCode() == HttpStatus.SC_OK
|
||||
&& "/ews/services.wsdl".equalsIgnoreCase(method.getPath())) {
|
||||
// direct EWS access returned wsdl
|
||||
authenticated = true;
|
||||
} else {
|
||||
// check cookies
|
||||
for (Cookie cookie : httpClient.getState().getCookies()) {
|
||||
// Exchange 2003 cookies
|
||||
if (cookie.getName().startsWith("cadata") || "sessionid".equals(cookie.getName())
|
||||
// Exchange 2007 cookie
|
||||
|| "UserContext".equals(cookie.getName())
|
||||
// Direct EWS access
|
||||
|| "exchangecookie".equals(cookie.getName())
|
||||
) {
|
||||
authenticated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return authenticated;
|
||||
|
Loading…
Reference in New Issue
Block a user