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

LDAP: fix DIGEST-MD5 SASL authentication for OSX Lion

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1798 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-09-26 23:45:17 +00:00
parent 34f31bbd44
commit 44c87d9c05
2 changed files with 16 additions and 9 deletions

View File

@ -96,6 +96,16 @@ public final class ExchangeSessionFactory {
}
}
private static String convertUserName(String userName) {
String result = userName;
// prepend default windows domain prefix
String defaultDomain = Settings.getProperty("davmail.defaultDomain");
if (userName.indexOf('\\') < 0 && defaultDomain != null) {
result = defaultDomain + '\\' + userName;
}
return result;
}
/**
* Create authenticated Exchange session
*
@ -109,12 +119,7 @@ public final class ExchangeSessionFactory {
ExchangeSession session = null;
try {
// prepend default windows domain prefix
String defaultDomain = Settings.getProperty("davmail.defaultDomain");
if (userName.indexOf('\\') < 0 && defaultDomain != null) {
userName = defaultDomain + '\\' + userName;
}
PoolKey poolKey = new PoolKey(baseUrl, userName, password);
PoolKey poolKey = new PoolKey(baseUrl, convertUserName(userName), password);
synchronized (LOCK) {
session = POOL_MAP.get(poolKey);
@ -263,8 +268,9 @@ public final class ExchangeSessionFactory {
* @return user password
*/
public static String getUserPassword(String userName) {
String fullUserName = convertUserName(userName);
for (PoolKey poolKey : POOL_MAP.keySet()) {
if (poolKey.userName.equals(userName)) {
if (poolKey.userName.equals(fullUserName)) {
return poolKey.password;
}
}

View File

@ -510,7 +510,7 @@ public class LdapConnection extends AbstractConnection {
protected static final byte[] EMPTY_BYTE_ARRAY= new byte[0];
protected void handleRequest(byte[] inbuf, int offset) throws IOException {
dumpBer(inbuf, offset);
//dumpBer(inbuf, offset);
BerDecoder reqBer = new BerDecoder(inbuf, 0, offset);
int currentMessageId = 0;
try {
@ -575,7 +575,7 @@ public class LdapConnection extends AbstractConnection {
} else {
Map<String, String> properties = new HashMap<String, String>();
properties.put("javax.security.sasl.qop", "auth,auth-int");
saslServer = Sasl.createSaslServer(mechanism, "ldap", InetAddress.getLocalHost().getHostName(), properties, callbackHandler);
saslServer = Sasl.createSaslServer(mechanism, "ldap", client.getLocalAddress().getHostAddress(), properties, callbackHandler);
serverResponse = saslServer.evaluateResponse(EMPTY_BYTE_ARRAY);
status = LDAP_SASL_BIND_IN_PROGRESS;
}
@ -792,6 +792,7 @@ public class LdapConnection extends AbstractConnection {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("objectClass", "top");
attributes.put("namingContexts", NAMING_CONTEXTS);
//attributes.put("supportedsaslmechanisms", "PLAIN");
sendEntry(currentMessageId, "Root DSE", attributes);
}