From 83cb84e579fdd19bbc42c2c3c6a13f87ce8b1bed Mon Sep 17 00:00:00 2001 From: mguessan Date: Sun, 25 Oct 2009 22:24:53 +0000 Subject: [PATCH] Detect redirect form instead of logon form, follow redirect to logon form git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@789 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 751cd97f..390d5993 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -285,6 +285,8 @@ public class ExchangeSession { if (path.startsWith("/")) { // path is absolute, replace method path uri.setPath(path); + } else if (path.startsWith("http://") || path.startsWith("https://")){ + return path; } else { // relative path, build new path String currentPath = method.getPath(); @@ -363,6 +365,10 @@ public class ExchangeSession { userNameInput = "txtUserName"; } else if ("txtUserPass".equals(name)) { passwordInput = "txtUserPass"; + } else if ("addr".equals(name)) { + // this is not a logon form but a redirect form + HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod); + logonMethod = buildLogonMethod(httpClient, newInitMethod); } } } else { @@ -757,7 +763,7 @@ public class ExchangeSession { " ,\"http://schemas.microsoft.com/mapi/proptag/x0E070003\", \"http://schemas.microsoft.com/mapi/proptag/x10810003\"" + " ,\"urn:schemas:mailheader:message-id\", \"urn:schemas:httpmail:read\" " + " ,\"http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/0x8570\" as deleted, \"urn:schemas:mailheader:date\"", conditions); - } + } /** * Search folder for messages matching conditions, with given attributes. @@ -1750,7 +1756,7 @@ public class ExchangeSession { for (File file : oldestFiles) { if (!file.delete()) { LOGGER.warn("Unable to delete " + file.getAbsolutePath()); - } + } } } catch (Exception ex) { LOGGER.warn("Error deleting ics dump: " + ex.getMessage());