1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 11:12:22 -05:00

Allow custom form with userid/pw fields in form based authentication

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@808 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-11-01 22:27:23 +00:00
parent ec17aa2e15
commit 8331fc8b6c
2 changed files with 20 additions and 5 deletions

View File

@ -18,6 +18,8 @@
*/
package davmail.exception;
import davmail.BundleMessage;
/**
* I18 AuthenticationException subclass.
*/
@ -30,4 +32,14 @@ public class DavMailAuthenticationException extends DavMailException {
public DavMailAuthenticationException(String key) {
super(key);
}
/**
* Create a DavMail authentication exception with the given BundleMessage key and arguments.
*
* @param key message key
*/
public DavMailAuthenticationException(String key, Object... arguments) {
super(key, arguments);
}
}

View File

@ -366,10 +366,10 @@ public class ExchangeSession {
logonMethod.addParameter(name, value);
}
// custom login form
if ("txtUserName".equals(name)) {
userNameInput = "txtUserName";
} else if ("txtUserPass".equals(name)) {
passwordInput = "txtUserPass";
if ("txtUserName".equals(name) || "userid".equals(name)) {
userNameInput = name;
} else if ("txtUserPass".equals(name) || "pw".equals(name)) {
passwordInput = name;
} else if ("addr".equals(name)) {
// this is not a logon form but a redirect form
HttpMethod newInitMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod);
@ -450,6 +450,9 @@ public class ExchangeSession {
throw new DavMailException("EXCEPTION_AUTHENTICATION_FORM_NOT_FOUND", initmethod.getURI());
}
// make sure username and password fields are empty
((PostMethod) logonMethod).removeParameter(userNameInput);
((PostMethod) logonMethod).removeParameter(passwordInput);
((PostMethod) logonMethod).addParameter(userNameInput, userName);
((PostMethod) logonMethod).addParameter(passwordInput, password);
((PostMethod) logonMethod).addParameter("trusted", "4");
@ -628,7 +631,7 @@ public class ExchangeSession {
);
} catch (IOException e) {
LOGGER.error(e.getMessage());
throw new DavMailException("EXCEPTION_UNABLE_TO_GET_MAIL_FOLDER", mailPath);
throw new DavMailAuthenticationException("EXCEPTION_UNABLE_TO_GET_MAIL_FOLDER", mailPath);
}
}