CLOUDSTACK-5236 : ability to identify where the user is from (ex. LDAP)

Added a source column to the user table.

Source now has only two values UNKNOWN,LDAP with UNKNOWN being the
default and is an enum is com.cloud.User.

When the source is UNKNOWN, the old method of authenticating against all
the available authenticators is used. If a source is available, only
that particular authenticator will be used.

added overloaded methods in AccountService to createUserAccount and
createUser with source specified.

(cherry picked from commit 5da733072e838c830720909ef5ba27ef6ce6d0b0)
This commit is contained in:
Rajani Karuturi 2014-10-21 15:30:57 +05:30
parent 2783cf540b
commit 843f6b1691
28 changed files with 167 additions and 60 deletions

View File

@ -59,6 +59,9 @@ public interface AccountService {
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName,
short accountType, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID); short accountType, Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID);
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
Map<String, String> details, String accountUUID, String userUUID, User.Source source);
/** /**
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses * Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
* allocated/etc. * allocated/etc.
@ -72,8 +75,10 @@ public interface AccountService {
User getSystemUser(); User getSystemUser();
User User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID);
createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID);
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID,
User.Source source);
boolean isAdmin(Long accountId); boolean isAdmin(Long accountId);

View File

@ -21,6 +21,11 @@ import java.util.Date;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
public interface User extends OwnedBy, InternalIdentity { public interface User extends OwnedBy, InternalIdentity {
public enum Source {
LDAP, UNKNOWN
}
public static final long UID_SYSTEM = 1; public static final long UID_SYSTEM = 1;
public static final long UID_ADMIN = 2; public static final long UID_ADMIN = 2;
@ -77,4 +82,6 @@ public interface User extends OwnedBy, InternalIdentity {
boolean isDefault(); boolean isDefault();
public Source getSource();
} }

View File

@ -61,4 +61,6 @@ public interface UserAccount extends InternalIdentity {
boolean isRegistered(); boolean isRegistered();
int getLoginAttempts(); int getLoginAttempts();
public User.Source getSource();
} }

View File

@ -20,6 +20,8 @@ import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
@ -99,6 +101,10 @@ public class UserAccountVO implements UserAccount, InternalIdentity {
@Column(name = "state", table = "account", insertable = false, updatable = false) @Column(name = "state", table = "account", insertable = false, updatable = false)
private String accountState; private String accountState;
@Column(name = "source")
@Enumerated(value = EnumType.STRING)
private User.Source source;
public UserAccountVO() { public UserAccountVO() {
} }
@ -281,4 +287,13 @@ public class UserAccountVO implements UserAccount, InternalIdentity {
public int getLoginAttempts() { public int getLoginAttempts() {
return loginAttempts; return loginAttempts;
} }
@Override
public User.Source getSource() {
return source;
}
public void setSource(User.Source source) {
this.source = source;
}
} }

View File

@ -97,6 +97,10 @@ public class UserVO implements User, Identity, InternalIdentity {
@Column(name = "default") @Column(name = "default")
boolean isDefault; boolean isDefault;
@Column(name = "source")
@Enumerated(value = EnumType.STRING)
private Source source;
public UserVO() { public UserVO() {
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
} }
@ -106,7 +110,7 @@ public class UserVO implements User, Identity, InternalIdentity {
this.uuid = UUID.randomUUID().toString(); this.uuid = UUID.randomUUID().toString();
} }
public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid) { public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, Source source) {
this.accountId = accountId; this.accountId = accountId;
this.username = username; this.username = username;
this.password = password; this.password = password;
@ -116,6 +120,7 @@ public class UserVO implements User, Identity, InternalIdentity {
this.timezone = timezone; this.timezone = timezone;
this.state = State.enabled; this.state = State.enabled;
this.uuid = uuid; this.uuid = uuid;
this.source = source;
} }
@Override @Override
@ -270,4 +275,12 @@ public class UserVO implements User, Identity, InternalIdentity {
return isDefault; return isDefault;
} }
public Source getSource() {
return source;
}
public void setSource(Source source) {
this.source = source;
}
} }

View File

@ -26,8 +26,11 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.User;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.cloudstack.dedicated.DedicatedResourceManagerImpl;
import org.apache.cloudstack.test.utils.SpringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -49,9 +52,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.apache.cloudstack.affinity.AffinityGroupService; import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.dedicated.DedicatedResourceManagerImpl;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.dc.DedicatedResourceVO; import com.cloud.dc.DedicatedResourceVO;
import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.ClusterDao;
@ -118,7 +119,7 @@ public class DedicatedApiUnitTest {
AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid"); AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain"); DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
when(_acctMgr.finalizeOwner((Account)anyObject(), anyString(), anyLong(), anyLong())).thenReturn(account); when(_acctMgr.finalizeOwner((Account)anyObject(), anyString(), anyLong(), anyLong())).thenReturn(account);

View File

@ -34,6 +34,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.User;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -164,7 +165,7 @@ public class ImplicitPlannerTest {
acct.setDomainId(domainId); acct.setDomainId(domainId);
acct.setId(accountId); acct.setId(accountId);
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, acct); CallContext.register(user, acct);
} }
@ -592,4 +593,4 @@ public class ImplicitPlannerTest {
} }
} }
} }
} }

View File

@ -30,6 +30,7 @@ import com.cloud.network.Networks;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.AccountManager; import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO; import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao; import com.cloud.user.dao.UserDao;
@ -256,6 +257,7 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
user.setFirstname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME); user.setFirstname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
user.setLastname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME); user.setLastname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
user.setPassword(UUID.randomUUID().toString()); user.setPassword(UUID.randomUUID().toString());
user.setSource(User.Source.UNKNOWN);
user = userDao.persist(user); user = userDao.persist(user);
String[] keys = acntMgr.createApiKeyAndSecretKey(user.getId()); String[] keys = acntMgr.createApiKeyAndSecretKey(user.getId());

View File

@ -27,6 +27,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import com.cloud.user.User;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -177,7 +178,7 @@ public class VmwareDatacenterApiUnitTest {
acct.setAccountName("admin"); acct.setAccountName("admin");
acct.setDomainId(domainId); acct.setDomainId(domainId);
UserVO user1 = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user1 = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user1, acct); CallContext.register(user1, acct);

View File

@ -127,6 +127,12 @@ public class MockAccountManager extends ManagerBase implements AccountManager {
return null; return null;
} }
@Override public User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId,
String userUUID, User.Source source) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public UserAccount createUserAccount(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, short arg7, Long arg8, String arg9, public UserAccount createUserAccount(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, short arg7, Long arg8, String arg9,
Map<String, String> arg10, String arg11, String arg12) { Map<String, String> arg10, String arg11, String arg12) {
@ -134,6 +140,13 @@ public class MockAccountManager extends ManagerBase implements AccountManager {
return null; return null;
} }
@Override
public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType,
Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public Account finalizeOwner(Account arg0, String arg1, Long arg2, Long arg3) { public Account finalizeOwner(Account arg0, String arg1, Long arg2, Long arg3) {
return _systemAccount; return _systemAccount;

View File

@ -92,10 +92,10 @@ public class LdapCreateAccountCmd extends BaseCmd {
Account account = _accountService.getActiveAccountByName(accountName, domainId); Account account = _accountService.getActiveAccountByName(accountName, domainId);
if (account == null) { if (account == null) {
return _accountService.createUserAccount(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, accountType, return _accountService.createUserAccount(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, accountType,
domainId, networkDomain, details, accountUUID, userUUID); domainId, networkDomain, details, accountUUID, userUUID, User.Source.LDAP);
} else { } else {
User newUser = _accountService.createUser(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domainId, User newUser = _accountService.createUser(username, generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domainId,
userUUID); userUUID, User.Source.LDAP);
return _accountService.getUserAccountById(newUser.getId()); return _accountService.getUserAccountById(newUser.getId());
} }
} }

View File

@ -26,6 +26,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.UserAccount; import com.cloud.user.UserAccount;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
@ -111,14 +112,14 @@ public class LdapImportUsersCmd extends BaseListCmd {
if (account == null) { if (account == null) {
s_logger.debug("No account exists with name: " + accountName + " creating the account and an user with name: " + user.getUsername() + " in the account"); s_logger.debug("No account exists with name: " + accountName + " creating the account and an user with name: " + user.getUsername() + " in the account");
_accountService.createUserAccount(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, accountType, _accountService.createUserAccount(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, accountType,
domain.getId(), domain.getNetworkDomain(), details, UUID.randomUUID().toString(), UUID.randomUUID().toString()); domain.getId(), domain.getNetworkDomain(), details, UUID.randomUUID().toString(), UUID.randomUUID().toString(), User.Source.LDAP);
} else { } else {
// check if the user exists. if yes, call update // check if the user exists. if yes, call update
UserAccount csuser = _accountService.getActiveUserAccount(user.getUsername(), domain.getId()); UserAccount csuser = _accountService.getActiveUserAccount(user.getUsername(), domain.getId());
if(csuser == null) { if(csuser == null) {
s_logger.debug("No user exists with name: " + user.getUsername() + " creating a user in the account: " + accountName); s_logger.debug("No user exists with name: " + user.getUsername() + " creating a user in the account: " + accountName);
_accountService.createUser(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domain.getId(), _accountService.createUser(user.getUsername(), generatePassword(), user.getFirstname(), user.getLastname(), user.getEmail(), timezone, accountName, domain.getId(),
UUID.randomUUID().toString()); UUID.randomUUID().toString(), User.Source.LDAP);
} else { } else {
s_logger.debug("account with name: " + accountName + " exist and user with name: " + user.getUsername() + " exists in the account. Updating the account."); s_logger.debug("account with name: " + accountName + " exist and user with name: " + user.getUsername() + " exists in the account. Updating the account.");
_accountService.updateUser(csuser.getId(), user.getFirstname(), user.getLastname(), user.getEmail(), null, null, null, null, null); _accountService.updateUser(csuser.getId(), user.getFirstname(), user.getLastname(), user.getEmail(), null, null, null, null, null);

View File

@ -21,6 +21,7 @@ import com.cloud.domain.DomainVO
import com.cloud.user.AccountService import com.cloud.user.AccountService
import com.cloud.user.AccountVO import com.cloud.user.AccountVO
import com.cloud.user.DomainService import com.cloud.user.DomainService
import com.cloud.user.User
import com.cloud.user.UserAccountVO import com.cloud.user.UserAccountVO
import com.cloud.user.UserVO import com.cloud.user.UserVO
import org.apache.cloudstack.api.command.LdapCreateAccountCmd import org.apache.cloudstack.api.command.LdapCreateAccountCmd
@ -214,8 +215,8 @@ class LdapImportUsersCmdSpec extends spock.lang.Specification {
def accountService = Mock(AccountService) def accountService = Mock(AccountService)
1 * accountService.getActiveAccountByName('ACCOUNT', 0) >> Mock(AccountVO) 1 * accountService.getActiveAccountByName('ACCOUNT', 0) >> Mock(AccountVO)
1 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 0, _) >> Mock(UserVO) 1 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 0, _, User.Source.LDAP) >> Mock(UserVO)
0 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _) 0 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _, User.Source.LDAP)
0 * accountService.updateUser(_,'Ryan', 'Murphy', 'rmurphy@test.com', null, null, null, null, null); 0 * accountService.updateUser(_,'Ryan', 'Murphy', 'rmurphy@test.com', null, null, null, null, null);
def ldapImportUsersCmd = new LdapImportUsersCmd(ldapManager, domainService, accountService) def ldapImportUsersCmd = new LdapImportUsersCmd(ldapManager, domainService, accountService)
@ -272,8 +273,8 @@ class LdapImportUsersCmdSpec extends spock.lang.Specification {
def accountService = Mock(AccountService) def accountService = Mock(AccountService)
1 * accountService.getActiveAccountByName('ACCOUNT', 0) >> null 1 * accountService.getActiveAccountByName('ACCOUNT', 0) >> null
0 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 0, _) 0 * accountService.createUser('rmurphy', _ , 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 0, _, User.Source.LDAP)
1 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _) 1 * accountService.createUserAccount('rmurphy', _, 'Ryan', 'Murphy', 'rmurphy@test.com', null, 'ACCOUNT', 2, 0, 'DOMAIN', null, _, _, User.Source.LDAP)
0 * accountService.updateUser(_,'Ryan', 'Murphy', 'rmurphy@test.com', null, null, null, null, null); 0 * accountService.updateUser(_,'Ryan', 'Murphy', 'rmurphy@test.com', null, null, null, null, null);
def ldapImportUsersCmd = new LdapImportUsersCmd(ldapManager, domainService, accountService) def ldapImportUsersCmd = new LdapImportUsersCmd(ldapManager, domainService, accountService)

View File

@ -987,6 +987,13 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
return success; return success;
} }
public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email, final String timezone,
String accountName, final short accountType, Long domainId, final String networkDomain, final Map<String, String> details, String accountUUID, final String userUUID) {
return createUserAccount(userName, password, firstName, lastName, email, timezone, accountName, accountType, domainId, networkDomain, details, accountUUID, userUUID,
User.Source.UNKNOWN);
}
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
// ////////////// API commands ///////////////////// // ////////////// API commands /////////////////////
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
@ -999,7 +1006,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
}) })
public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email, public UserAccount createUserAccount(final String userName, final String password, final String firstName, final String lastName, final String email,
final String timezone, String accountName, final short accountType, Long domainId, final String networkDomain, final Map<String, String> details, final String timezone, String accountName, final short accountType, Long domainId, final String networkDomain, final Map<String, String> details,
String accountUUID, final String userUUID) { String accountUUID, final String userUUID, final User.Source source) {
if (accountName == null) { if (accountName == null) {
accountName = userName; accountName = userName;
@ -1056,7 +1063,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
long accountId = account.getId(); long accountId = account.getId();
// create the first user for the account // create the first user for the account
UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone, userUUID); UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone, userUUID, source);
if (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { if (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
// set registration token // set registration token
@ -1088,8 +1095,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
@Override @Override
@ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User") @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User")
public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId,
String userUUID) { String userUUID, User.Source source) {
// default domain to ROOT if not specified // default domain to ROOT if not specified
if (domainId == null) { if (domainId == null) {
domainId = Domain.ROOT_DOMAIN; domainId = Domain.ROOT_DOMAIN;
@ -1117,10 +1123,17 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
throw new CloudRuntimeException("The user " + userName + " already exists in domain " + domainId); throw new CloudRuntimeException("The user " + userName + " already exists in domain " + domainId);
} }
UserVO user = null; UserVO user = null;
user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone, userUUID); user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone, userUUID, source);
return user; return user;
} }
@Override
public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId,
String userUUID) {
return createUser(userName, password, firstName,lastName, email, timeZone, accountName, domainId, userUUID, User.Source.UNKNOWN);
}
@Override @Override
@ActionEvent(eventType = EventTypes.EVENT_USER_UPDATE, eventDescription = "updating User") @ActionEvent(eventType = EventTypes.EVENT_USER_UPDATE, eventDescription = "updating User")
public UserAccount updateUser(Long userId, String firstName, String lastName, String email, String userName, String password, String apiKey, String secretKey, String timeZone) { public UserAccount updateUser(Long userId, String firstName, String lastName, String email, String userName, String password, String apiKey, String secretKey, String timeZone) {
@ -1963,7 +1976,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
}); });
} }
protected UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID) { protected UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID,
User.Source source) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone);
} }
@ -1982,7 +1996,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
if (userUUID == null) { if (userUUID == null) {
userUUID = UUID.randomUUID().toString(); userUUID = UUID.randomUUID().toString();
} }
UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, userUUID)); UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, userUUID, source));
CallContext.current().putContextParameter(User.class, user.getUuid()); CallContext.current().putContextParameter(User.class, user.getUuid());
return user; return user;
} }
@ -2126,10 +2140,21 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Attempting to log in user: " + username + " in domain " + domainId); s_logger.debug("Attempting to log in user: " + username + " in domain " + domainId);
} }
UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId);
if (userAccount == null) {
s_logger.warn("Unable to find an user with username " + username + " in domain " + domainId);
return null;
}
boolean authenticated = false; boolean authenticated = false;
HashSet<ActionOnFailedAuthentication> actionsOnFailedAuthenticaion = new HashSet<ActionOnFailedAuthentication>(); HashSet<ActionOnFailedAuthentication> actionsOnFailedAuthenticaion = new HashSet<ActionOnFailedAuthentication>();
User.Source userSource = userAccount.getSource();
for (UserAuthenticator authenticator : _userAuthenticators) { for (UserAuthenticator authenticator : _userAuthenticators) {
if(userSource != User.Source.UNKNOWN) {
if(!authenticator.getName().equalsIgnoreCase(userSource.name())){
continue;
}
}
Pair<Boolean, ActionOnFailedAuthentication> result = authenticator.authenticate(username, password, domainId, requestParameters); Pair<Boolean, ActionOnFailedAuthentication> result = authenticator.authenticate(username, password, domainId, requestParameters);
if (result.first()) { if (result.first()) {
authenticated = true; authenticated = true;
@ -2142,11 +2167,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
boolean updateIncorrectLoginCount = actionsOnFailedAuthenticaion.contains(ActionOnFailedAuthentication.INCREMENT_INCORRECT_LOGIN_ATTEMPT_COUNT); boolean updateIncorrectLoginCount = actionsOnFailedAuthenticaion.contains(ActionOnFailedAuthentication.INCREMENT_INCORRECT_LOGIN_ATTEMPT_COUNT);
if (authenticated) { if (authenticated) {
UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId);
if (userAccount == null) {
s_logger.warn("Unable to find an authenticated user with username " + username + " in domain " + domainId);
return null;
}
Domain domain = _domainMgr.getDomain(domainId); Domain domain = _domainMgr.getDomain(domainId);
String domainName = null; String domainName = null;
@ -2172,7 +2192,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
s_logger.debug("Unable to authenticate user with username " + username + " in domain " + domainId); s_logger.debug("Unable to authenticate user with username " + username + " in domain " + domainId);
} }
UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId);
if (userAccount != null) { if (userAccount != null) {
if (userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString())) { if (userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString())) {
if (!isInternalAccount(userAccount.getId())) { if (!isInternalAccount(userAccount.getId())) {

View File

@ -22,6 +22,7 @@ import java.util.UUID;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO; import com.cloud.user.UserVO;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.junit.Test; import org.junit.Test;
@ -42,7 +43,7 @@ public class CommandCreationWorkerTest {
final BaseAsyncCreateCmd asyncCreateCmd = mock(BaseAsyncCreateCmd.class); final BaseAsyncCreateCmd asyncCreateCmd = mock(BaseAsyncCreateCmd.class);
final Map<String, String> params = new HashMap<String, String>(); final Map<String, String> params = new HashMap<String, String>();
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
// Execute // Execute

View File

@ -106,7 +106,7 @@ public class ParamGenericValidationWorkerTest {
params.put("addedParam", ""); params.put("addedParam", "");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
// Execute // Execute
try { try {
@ -130,7 +130,7 @@ public class ParamGenericValidationWorkerTest {
params.put(unknownParamKey, ""); params.put(unknownParamKey, "");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
// Execute // Execute
@ -172,7 +172,7 @@ public class ParamGenericValidationWorkerTest {
final Account account = mock(Account.class); final Account account = mock(Account.class);
((FakeCmdWithRoleAdmin)cmd).account = account; ((FakeCmdWithRoleAdmin)cmd).account = account;
when(account.getType()).thenReturn(type); when(account.getType()).thenReturn(type);
User user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); User user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
final Map<String, String> params = new HashMap<String, String>(); final Map<String, String> params = new HashMap<String, String>();

View File

@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.cloud.user.User;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
@ -138,7 +139,7 @@ public class ConfigurationManagerTest {
when(configurationMgr._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account); when(configurationMgr._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account);
when(configurationMgr._accountMgr.getActiveAccountById(anyLong())).thenReturn(account); when(configurationMgr._accountMgr.getActiveAccountById(anyLong())).thenReturn(account);
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
when(configurationMgr._publicIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(1); when(configurationMgr._publicIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(1);

View File

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.cloud.user.User;
import junit.framework.Assert; import junit.framework.Assert;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -100,7 +101,7 @@ public class DedicateGuestVlanRangesTest {
when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account); when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account);
when(networkService._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account); when(networkService._accountDao.findActiveAccount(anyString(), anyLong())).thenReturn(account);
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);

View File

@ -32,6 +32,7 @@ import com.cloud.network.rules.RulesManagerImpl;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.AccountManager; import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO; import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
import com.cloud.uservm.UserVm; import com.cloud.uservm.UserVm;
@ -137,7 +138,7 @@ public class AssignLoadBalancerTest {
AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid"); AccountVO account = new AccountVO(accountName, domainId, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain"); DomainVO domain = new DomainVO("rootDomain", 5L, 5L, "networkDomain");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);

View File

@ -27,6 +27,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.User;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
@ -105,7 +106,7 @@ public class VolumeApiServiceImplTest {
// mock caller context // mock caller context
AccountVO account = new AccountVO("admin", 1L, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid"); AccountVO account = new AccountVO("admin", 1L, "networkDomain", Account.ACCOUNT_TYPE_NORMAL, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
// mock async context // mock async context
AsyncJobExecutionContext context = new AsyncJobExecutionContext(); AsyncJobExecutionContext context = new AsyncJobExecutionContext();

View File

@ -336,8 +336,22 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco
} }
@Override @Override
public User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType,
String userUUID) { Long domainId, String networkDomain, Map<String, String> details, String accountUUID, String userUUID, User.Source source) {
// TODO Auto-generated method stub
return null;
}
@Override
public User createUser(String userName, String password, String firstName,
String lastName, String email, String timeZone, String accountName,
Long domainId, String userUUID) {
// TODO Auto-generated method stub
return null;
}
@Override public User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId,
String userUUID, User.Source source) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }

View File

@ -37,6 +37,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.user.User;
import com.cloud.event.dao.UsageEventDao; import com.cloud.event.dao.UsageEventDao;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -209,7 +210,7 @@ public class UserVmManagerTest {
when(_templateDao.findById(anyLong())).thenReturn(_templateMock); when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
doReturn(VirtualMachine.State.Error).when(_vmMock).getState(); doReturn(VirtualMachine.State.Error).when(_vmMock).getState();
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
try { try {
@ -239,7 +240,7 @@ public class UserVmManagerTest {
when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735"); when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
StoragePoolVO storagePool = new StoragePoolVO(); StoragePoolVO storagePool = new StoragePoolVO();
@ -276,7 +277,7 @@ public class UserVmManagerTest {
when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735"); when(_templateMock.getUuid()).thenReturn("e0552266-7060-11e2-bbaa-d55f5db67735");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
StoragePoolVO storagePool = new StoragePoolVO(); StoragePoolVO storagePool = new StoragePoolVO();
@ -321,7 +322,7 @@ public class UserVmManagerTest {
when(_templateMock.getUuid()).thenReturn("b1a3626e-72e0-4697-8c7c-a110940cc55d"); when(_templateMock.getUuid()).thenReturn("b1a3626e-72e0-4697-8c7c-a110940cc55d");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
StoragePoolVO storagePool = new StoragePoolVO(); StoragePoolVO storagePool = new StoragePoolVO();
@ -368,7 +369,7 @@ public class UserVmManagerTest {
when(_templateMock.getUuid()).thenReturn("b1a3626e-72e0-4697-8c7c-a110940cc55d"); when(_templateMock.getUuid()).thenReturn("b1a3626e-72e0-4697-8c7c-a110940cc55d");
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
StoragePoolVO storagePool = new StoragePoolVO(); StoragePoolVO storagePool = new StoragePoolVO();
@ -406,7 +407,7 @@ public class UserVmManagerTest {
// UserContext.current().setEventDetails("Vm Id: "+getId()); // UserContext.current().setEventDetails("Vm Id: "+getId());
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid"); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, "uuid");
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
//AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId) //AccountVO(String accountName, long domainId, String networkDomain, short type, int regionId)
doReturn(VirtualMachine.State.Running).when(_vmInstance).getState(); doReturn(VirtualMachine.State.Running).when(_vmInstance).getState();
@ -450,7 +451,7 @@ public class UserVmManagerTest {
when(_offeringDao.findByIdIncludingRemoved(anyLong(), anyLong())).thenReturn((ServiceOfferingVO)so1); when(_offeringDao.findByIdIncludingRemoved(anyLong(), anyLong())).thenReturn((ServiceOfferingVO)so1);
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
try { try {
_userVmMgr.upgradeVirtualMachine(cmd); _userVmMgr.upgradeVirtualMachine(cmd);
@ -492,7 +493,7 @@ public class UserVmManagerTest {
//when(_vmDao.findById(anyLong())).thenReturn(_vmMock); //when(_vmDao.findById(anyLong())).thenReturn(_vmMock);
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
try { try {
_userVmMgr.upgradeVirtualMachine(cmd); _userVmMgr.upgradeVirtualMachine(cmd);
@ -541,7 +542,7 @@ public class UserVmManagerTest {
when(_vmDao.findById(anyLong())).thenReturn(_vmMock); when(_vmDao.findById(anyLong())).thenReturn(_vmMock);
Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1L, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
try { try {
_userVmMgr.upgradeVirtualMachine(cmd); _userVmMgr.upgradeVirtualMachine(cmd);
@ -589,7 +590,7 @@ public class UserVmManagerTest {
// caller is of type 0 // caller is of type 0
Account caller = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString()); Account caller = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, caller); CallContext.register(user, caller);
try { try {
@ -620,7 +621,7 @@ public class UserVmManagerTest {
// caller is of type 0 // caller is of type 0
Account caller = new AccountVO("testaccount", 1, "networkdomain", (short)1, UUID.randomUUID().toString()); Account caller = new AccountVO("testaccount", 1, "networkdomain", (short)1, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
Account oldAccount = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString()); Account oldAccount = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
Account newAccount = new AccountVO("testaccount", 1, "networkdomain", (short)1, UUID.randomUUID().toString()); Account newAccount = new AccountVO("testaccount", 1, "networkdomain", (short)1, UUID.randomUUID().toString());

View File

@ -22,6 +22,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.User;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
@ -110,7 +111,7 @@ public class NetworkACLManagerTest extends TestCase {
public void setUp() { public void setUp() {
ComponentContext.initComponentsLifeCycle(); ComponentContext.initComponentsLifeCycle();
Account account = new AccountVO("testaccount", 1, "testdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1, "testdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
acl = Mockito.mock(NetworkACLVO.class); acl = Mockito.mock(NetworkACLVO.class);

View File

@ -20,6 +20,7 @@ import java.util.UUID;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.user.User;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd; import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
@ -103,7 +104,7 @@ public class NetworkACLServiceTest extends TestCase {
public void setUp() { public void setUp() {
ComponentContext.initComponentsLifeCycle(); ComponentContext.initComponentsLifeCycle();
Account account = new AccountVO("testaccount", 1, "testdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1, "testdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);

View File

@ -33,6 +33,11 @@ import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import com.cloud.utils.db.EntityManager; import com.cloud.utils.db.EntityManager;
import com.cloud.event.ActionEventUtils;
import com.cloud.user.User;
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.test.utils.SpringUtils;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -53,17 +58,13 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.test.context.support.AnnotationConfigContextLoader;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao; import org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.MessageBus;
import org.apache.cloudstack.test.utils.SpringUtils;
import com.cloud.dc.dao.DedicatedResourceDao; import com.cloud.dc.dao.DedicatedResourceDao;
import com.cloud.domain.dao.DomainDao; import com.cloud.domain.dao.DomainDao;
import com.cloud.event.ActionEventUtils;
import com.cloud.event.EventVO; import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao; import com.cloud.event.dao.EventDao;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -137,7 +138,7 @@ public class AffinityApiUnitTest {
acct.setAccountName("user"); acct.setAccountName("user");
acct.setDomainId(domainId); acct.setDomainId(domainId);
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, acct); CallContext.register(user, acct);

View File

@ -32,6 +32,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd; import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
import com.cloud.user.User;
import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd; import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.junit.After; import org.junit.After;
@ -60,7 +61,7 @@ public class CertServiceTest {
@Before @Before
public void setUp() { public void setUp() {
Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
} }

View File

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.cloud.user.User;
import junit.framework.Assert; import junit.framework.Assert;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -70,7 +71,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
public void setUp() { public void setUp() {
Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString()); Account account = new AccountVO("testaccount", 1, "networkdomain", (short)0, UUID.randomUUID().toString());
UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString()); UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account); CallContext.register(user, account);
} }

View File

@ -24,3 +24,4 @@ UPDATE IGNORE `cloud`.`configuration` SET `value`='PBKDF2,SHA256SALT,MD5,LDAP,SA
UPDATE IGNORE `cloud`.`configuration` SET `default_value`='PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT' WHERE name='user.password.encoders.order'; UPDATE IGNORE `cloud`.`configuration` SET `default_value`='PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT' WHERE name='user.password.encoders.order';
UPDATE IGNORE `cloud`.`configuration` SET `value`='PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT' WHERE name='user.password.encoders.order'; UPDATE IGNORE `cloud`.`configuration` SET `value`='PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT' WHERE name='user.password.encoders.order';
UPDATE IGNORE `cloud`.`configuration` SET `value`="MD5,LDAP,PLAINTEXT" WHERE `name`="user.password.encoders.exclude"; UPDATE IGNORE `cloud`.`configuration` SET `value`="MD5,LDAP,PLAINTEXT" WHERE `name`="user.password.encoders.exclude";
ALTER TABLE `cloud`.`user` ADD COLUMN `source` varchar(40) NOT NULL DEFAULT 'UNKNOWN';