bug 11303: passing the request params to the authenticators, callingh authenticators in a configurable chain

This commit is contained in:
Abhinandan Prateek 2012-01-02 14:55:26 +05:30
parent a60d8cea86
commit 4f9cbdaadb
4 changed files with 8 additions and 7 deletions

View File

@ -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<String, Object[]> requestParameters ) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Retrieving user: " + username);
}

View File

@ -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<String, Object[]> requestParameters ) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Retrieving user: " + username);
}

View File

@ -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<String, Object[]> requestParameters);
}

View File

@ -1549,7 +1549,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
public UserAccount authenticateUser(String username, String password, Long domainId, Map<String, Object[]> 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<String, Object[]> 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<UserAuthenticator> 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;
}