From 4f9cbdaadb0518190542ca8d7710667a5644fd2a Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Mon, 2 Jan 2012 14:55:26 +0530 Subject: [PATCH] bug 11303: passing the request params to the authenticators, callingh authenticators in a configurable chain --- .../src/com/cloud/server/auth/LDAPUserAuthenticator.java | 2 +- server/src/com/cloud/server/auth/MD5UserAuthenticator.java | 2 +- server/src/com/cloud/server/auth/UserAuthenticator.java | 4 +++- server/src/com/cloud/user/AccountManagerImpl.java | 7 +++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/server/src/com/cloud/server/auth/LDAPUserAuthenticator.java b/server/src/com/cloud/server/auth/LDAPUserAuthenticator.java index 1cf3c41576f..9314ceb0961 100644 --- a/server/src/com/cloud/server/auth/LDAPUserAuthenticator.java +++ b/server/src/com/cloud/server/auth/LDAPUserAuthenticator.java @@ -52,7 +52,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator { private UserAccountDao _userAccountDao; @Override - public boolean authenticate(String username, String password, Long domainId) { + public boolean authenticate(String username, String password, Long domainId, Map requestParameters ) { if (s_logger.isDebugEnabled()) { s_logger.debug("Retrieving user: " + username); } diff --git a/server/src/com/cloud/server/auth/MD5UserAuthenticator.java b/server/src/com/cloud/server/auth/MD5UserAuthenticator.java index a93cc174089..d7ede7857d7 100644 --- a/server/src/com/cloud/server/auth/MD5UserAuthenticator.java +++ b/server/src/com/cloud/server/auth/MD5UserAuthenticator.java @@ -47,7 +47,7 @@ public class MD5UserAuthenticator extends DefaultUserAuthenticator { private UserAccountDao _userAccountDao; @Override - public boolean authenticate(String username, String password, Long domainId) { + public boolean authenticate(String username, String password, Long domainId, Map requestParameters ) { if (s_logger.isDebugEnabled()) { s_logger.debug("Retrieving user: " + username); } diff --git a/server/src/com/cloud/server/auth/UserAuthenticator.java b/server/src/com/cloud/server/auth/UserAuthenticator.java index bc27944a9df..172e3370244 100644 --- a/server/src/com/cloud/server/auth/UserAuthenticator.java +++ b/server/src/com/cloud/server/auth/UserAuthenticator.java @@ -18,6 +18,8 @@ package com.cloud.server.auth; +import java.util.Map; + import com.cloud.utils.component.Adapter; /** @@ -36,5 +38,5 @@ public interface UserAuthenticator extends Adapter { * @param domainId * @return true if the user has been successfully authenticated, false otherwise */ - public boolean authenticate(String username, String password, Long domainId); + public boolean authenticate(String username, String password, Long domainId, Map requestParameters); } diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 0baa2cdd70a..a7341393a32 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -1549,7 +1549,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag public UserAccount authenticateUser(String username, String password, Long domainId, Map requestParameters) { UserAccount user = null; if (password != null) { - user = getUserAccount(username, password, domainId); + user = getUserAccount(username, password, domainId, requestParameters); } else { String key = _configDao.getValue("security.singlesignon.key"); if (key == null) { @@ -1657,16 +1657,15 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag } } - private UserAccount getUserAccount(String username, String password, Long domainId) { + private UserAccount getUserAccount(String username, String password, Long domainId, Map requestParameters) { if (s_logger.isDebugEnabled()) { s_logger.debug("Attempting to log in user: " + username + " in domain " + domainId); } boolean authenticated = false; - // We only use the first adapter even if multiple have been configured for (Enumeration en = _userAuthenticators.enumeration(); en.hasMoreElements();){ UserAuthenticator authenticator = en.nextElement(); - if (authenticator.authenticate(username, password, domainId)){ + if (authenticator.authenticate(username, password, domainId, requestParameters)){ authenticated = true; break; }