From 21504d68280037332e56996f2d714a45a3a637c6 Mon Sep 17 00:00:00 2001 From: mguessan Date: Mon, 1 Feb 2010 23:20:56 +0000 Subject: [PATCH] Support multiple forms in form based authentication logon page git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@936 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 7db9a757..fc4c69b0 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -385,13 +385,23 @@ public class ExchangeSession { try { TagNode node = cleaner.clean(initmethod.getResponseBodyAsStream()); List forms = node.getElementListByName("form", true); + TagNode logonForm = null; + // select form if (forms.size() == 1) { - TagNode form = (TagNode) forms.get(0); - String logonMethodPath = form.getAttributeByName("action"); + logonForm = (TagNode) forms.get(0); + } else if (forms.size() > 1) { + for (Object form : forms) { + if ("logonForm".equals(((TagNode) form).getAttributeByName("name"))) { + logonForm = ((TagNode) form); + } + } + } + if (logonForm != null) { + String logonMethodPath = logonForm.getAttributeByName("action"); logonMethod = new PostMethod(getAbsoluteUri(initmethod, logonMethodPath)); - List inputList = form.getElementListByName("input", true); + List inputList = logonForm.getElementListByName("input", true); for (Object input : inputList) { String type = ((TagNode) input).getAttributeByName("type"); String name = ((TagNode) input).getAttributeByName("name"); @@ -1487,6 +1497,7 @@ public class ExchangeSession { /** * Set IMAP uid. + * * @param imapUid new uid */ public void setImapUid(long imapUid) {