New multiple user fields implementation: expect userid|username as login value

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1597 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-01-05 21:26:07 +00:00
parent 13132245c4
commit a00d322599
1 changed files with 18 additions and 9 deletions

View File

@ -127,7 +127,7 @@ public abstract class ExchangeSession {
protected String currentMailboxPath;
protected final HttpClient httpClient;
protected final String userName;
protected String userName;
protected String serverVersion;
@ -282,7 +282,7 @@ public abstract class ExchangeSession {
/**
* Test authentication mode : form based or basic.
*
* @param url exchange base URL
* @param url exchange base URL
* @param httpClient httpClient instance
* @return true if basic authentication detected
* @throws IOException unable to connect to exchange
@ -443,19 +443,28 @@ public abstract class ExchangeSession {
protected HttpMethod postLogonMethod(HttpClient httpClient, HttpMethod logonMethod, String userName, String password) throws IOException {
String userNameInput;
if (userNameInputs.isEmpty()) {
// should not happen
if (userNameInputs.size() == 2) {
// multiple username fields, split userid|username on |
int pipeIndex = userName.indexOf('|');
if (pipeIndex < 0) {
LOGGER.warn("Multiple user fields detected, please use userid|username as user name in client");
} else {
String userid = userName.substring(0, pipeIndex);
((PostMethod) logonMethod).removeParameter("userid");
((PostMethod) logonMethod).addParameter("userid", userid);
userName = userName.substring(pipeIndex + 1);
// adjust credentials
this.userName = userName;
DavGatewayHttpClientFacade.setCredentials(httpClient, userName, password);
}
userNameInput = "username";
} else if (userNameInputs.size() == 1) {
// simple username field
userNameInput = userNameInputs.get(0);
} else {
// multiple username fields, set domain\\username in username and email address in userid
// should not happen
userNameInput = "username";
String userid = getAliasFromLogin() + getEmailSuffixFromHostname();
((PostMethod) logonMethod).removeParameter("userid");
((PostMethod) logonMethod).addParameter("userid", userid);
}
// make sure username and password fields are empty
((PostMethod) logonMethod).removeParameter(userNameInput);