From 8b80ac6251e64f91bf20c4e57fd203d060fea9ca Mon Sep 17 00:00:00 2001 From: mguessan Date: Wed, 2 Sep 2009 16:37:33 +0000 Subject: [PATCH] Improve Form Based Logon: fix script based logon URI creation git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@691 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index d2868c44..9d19cc5c 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -262,8 +262,10 @@ public class ExchangeSession { URI uri = method.getURI(); if (path != null) { if (path.startsWith("/")) { + // path is absolute, replace method path uri.setPath(path); } else { + // relative path, build new path String currentPath = method.getPath(); int end = currentPath.lastIndexOf('/'); if (end >= 0) { @@ -335,9 +337,11 @@ public class ExchangeSession { int a_sUrlEndIndex = scriptValue.indexOf('\"', a_sUrlIndex); int a_sLgnEndIndex = scriptValue.indexOf('\"', a_sLgnIndex); if (a_sUrlEndIndex >= 0 && a_sLgnEndIndex >= 0) { - String src = getAbsoluteUri(initmethod, - scriptValue.substring(a_sLgnIndex, a_sLgnEndIndex) + + URI initmethodURI = initmethod.getURI(); + initmethodURI.setQuery( + scriptValue.substring(a_sLgnIndex + 1, a_sLgnEndIndex) + scriptValue.substring(a_sUrlIndex, a_sUrlEndIndex)); + String src = initmethodURI.getURI(); LOGGER.debug("Detected script based logon, redirect to form at " + src); HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src); logonMethod = buildLogonMethod(httpClient, newInitMethod); @@ -350,9 +354,11 @@ public class ExchangeSession { int a_sUrlEndIndex = scriptValue.indexOf('\"', a_sUrlIndex); int a_sLgnEndIndex = scriptValue.indexOf('\"', a_sLgnIndex); if (a_sUrlEndIndex >= 0 && a_sLgnEndIndex >= 0) { - String src = initmethod.getPath() + - scriptValue.substring(a_sLgnIndex, a_sLgnEndIndex) + - scriptValue.substring(a_sUrlIndex, a_sUrlEndIndex); + URI initmethodURI = initmethod.getURI(); + initmethodURI.setQuery( + scriptValue.substring(a_sLgnIndex + 1, a_sLgnEndIndex) + + scriptValue.substring(a_sUrlIndex, a_sUrlEndIndex)); + String src = initmethodURI.getURI(); LOGGER.debug("Detected script based logon, redirect to form at " + src); HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, src); logonMethod = buildLogonMethod(httpClient, newInitMethod);