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

Custom form (txtUserName, tstUserPass) support

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@706 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-09-08 08:05:05 +00:00
parent 4ace24e406
commit b36085f241

View File

@ -146,6 +146,15 @@ public class ExchangeSession {
private static final String YYYY_MM_DD_T_HHMMSS_Z = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static final String YYYY_MM_DD_T_HHMMSS_SSS_Z = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
/**
* Logon form user name field, default is username.
*/
private String userNameInput = "username";
/**
* Logon form password field, default is password.
*/
private String passwordInput = "password";
/**
* Create an exchange session for the given URL.
* The session is not actually established until a call to login()
@ -317,6 +326,12 @@ public class ExchangeSession {
if ("hidden".equalsIgnoreCase(type) && name != null && value != null) {
logonMethod.addParameter(name, value);
}
// custom login form
if ("txtUserName".equals(name)) {
userNameInput = "txtUserName";
} else if ("txtUserPass".equals(name)) {
passwordInput = "txtUserPass";
}
}
} else {
List frameList = node.getElementListByName("frame", true);
@ -395,8 +410,8 @@ public class ExchangeSession {
LOGGER.debug("Form based authentication detected");
HttpMethod logonMethod = buildLogonMethod(httpClient, initmethod);
((PostMethod) logonMethod).addParameter("username", userName);
((PostMethod) logonMethod).addParameter("password", password);
((PostMethod) logonMethod).addParameter(userNameInput, userName);
((PostMethod) logonMethod).addParameter(passwordInput, password);
((PostMethod) logonMethod).addParameter("trusted", "4");
logonMethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, logonMethod);