mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Changed account state to be in lower case.
This commit is contained in:
parent
0a3895a923
commit
dfecc1f448
@ -176,7 +176,7 @@ public abstract class BaseCmd {
|
||||
if (owner == null) {
|
||||
throw new InvalidParameterValueException("Invalid value for owner specified: " + accountName);
|
||||
}
|
||||
if (owner.getState() == Account.State.Disabled || owner.getState() == Account.State.Locked) {
|
||||
if (owner.getState() == Account.State.disabled || owner.getState() == Account.State.locked) {
|
||||
throw new PermissionDeniedException("Account disabled.");
|
||||
}
|
||||
return owner;
|
||||
|
||||
@ -31,9 +31,9 @@ public interface Account extends ControlledEntity {
|
||||
}
|
||||
|
||||
public enum State {
|
||||
Disabled,
|
||||
Enabled,
|
||||
Locked
|
||||
disabled,
|
||||
enabled,
|
||||
locked
|
||||
}
|
||||
|
||||
public static final short ACCOUNT_TYPE_NORMAL = 0;
|
||||
|
||||
@ -49,7 +49,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
|
||||
|
||||
@Override
|
||||
public boolean checkAccess(Account account, Domain domain) throws PermissionDeniedException {
|
||||
if (account.getState() != Account.State.Enabled) {
|
||||
if (account.getState() != Account.State.enabled) {
|
||||
throw new PermissionDeniedException(account + " is disabled.");
|
||||
}
|
||||
|
||||
|
||||
@ -598,7 +598,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
user = userAcctPair.first();
|
||||
Account account = userAcctPair.second();
|
||||
|
||||
if (user.getState() != Account.State.Enabled || !account.getState().equals(Account.State.Enabled)) {
|
||||
if (user.getState() != Account.State.enabled || !account.getState().equals(Account.State.enabled)) {
|
||||
s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState());
|
||||
return false;
|
||||
}
|
||||
@ -729,7 +729,7 @@ public class ApiServer implements HttpRequestHandler {
|
||||
account = _ms.findAccountById(user.getAccountId());
|
||||
}
|
||||
|
||||
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled) || (account == null) || !account.getState().equals(Account.State.Enabled)) {
|
||||
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled) || (account == null) || !account.getState().equals(Account.State.enabled)) {
|
||||
s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class DisableUserExecutor extends BaseAsyncJobExecutor {
|
||||
|
||||
List<UserVO> allUsersByAccount = asyncMgr.getExecutorContext().getUserDao().listByAccount(user.getAccountId());
|
||||
for (UserVO oneUser : allUsersByAccount) {
|
||||
if (oneUser.getState().equals(Account.State.Enabled)) {
|
||||
if (oneUser.getState().equals(Account.State.enabled)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ public class ManagementServerImpl implements ManagementServer {
|
||||
domainName = domain.getName();
|
||||
}
|
||||
|
||||
if (!userAccount.getState().equalsIgnoreCase(Account.State.Enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.Enabled.toString())) {
|
||||
if (!userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.enabled.toString())) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)");
|
||||
}
|
||||
|
||||
@ -406,8 +406,8 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
account = _ms.findAccountById(user.getAccountId());
|
||||
}
|
||||
|
||||
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.Enabled)
|
||||
|| (account == null) || !account.getState().equals(Account.State.Enabled)) {
|
||||
if ((user == null) || (user.getRemoved() != null) || !user.getState().equals(Account.State.enabled)
|
||||
|| (account == null) || !account.getState().equals(Account.State.enabled)) {
|
||||
s_logger.warn("Deleted/Disabled/Locked user with id=" + userId + " attempting to access public API");
|
||||
return false;
|
||||
}
|
||||
@ -474,7 +474,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
user = userAcctPair.first();
|
||||
Account account = userAcctPair.second();
|
||||
|
||||
if (!user.getState().equals(Account.State.Enabled) || !account.getState().equals(Account.State.Enabled)) {
|
||||
if (!user.getState().equals(Account.State.enabled) || !account.getState().equals(Account.State.enabled)) {
|
||||
s_logger.info("disabled or locked user accessing the api, userid = " + user.getId() + "; name = " + user.getUsername() + "; state: " + user.getState() + "; accountState: " + account.getState());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -747,7 +747,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
public boolean enableAccount(long accountId) {
|
||||
boolean success = false;
|
||||
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
||||
acctForUpdate.setState(State.Enabled);
|
||||
acctForUpdate.setState(State.enabled);
|
||||
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
|
||||
return success;
|
||||
}
|
||||
@ -756,11 +756,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
boolean success = false;
|
||||
Account account = _accountDao.findById(accountId);
|
||||
if (account != null) {
|
||||
if (account.getState().equals(State.Locked)) {
|
||||
if (account.getState().equals(State.locked)) {
|
||||
return true; // already locked, no-op
|
||||
} else if (account.getState().equals(State.Enabled)) {
|
||||
} else if (account.getState().equals(State.enabled)) {
|
||||
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
||||
acctForUpdate.setState(State.Locked);
|
||||
acctForUpdate.setState(State.locked);
|
||||
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
@ -956,11 +956,11 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
}
|
||||
|
||||
AccountVO account = _accountDao.findById(accountId);
|
||||
if ((account == null) || account.getState().equals(State.Disabled)) {
|
||||
if ((account == null) || account.getState().equals(State.disabled)) {
|
||||
success = true;
|
||||
} else {
|
||||
AccountVO acctForUpdate = _accountDao.createForUpdate();
|
||||
acctForUpdate.setState(State.Disabled);
|
||||
acctForUpdate.setState(State.disabled);
|
||||
success = _accountDao.update(Long.valueOf(accountId), acctForUpdate);
|
||||
|
||||
success = (success && doDisableAccount(accountId));
|
||||
@ -1044,7 +1044,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
newAccount.setAccountName(accountName);
|
||||
newAccount.setDomainId(domainId);
|
||||
newAccount.setType(userType);
|
||||
newAccount.setState(State.Enabled);
|
||||
newAccount.setState(State.enabled);
|
||||
newAccount.setNetworkDomain(networkDomain);
|
||||
newAccount = _accountDao.persist(newAccount);
|
||||
accountId = newAccount.getId();
|
||||
@ -1057,7 +1057,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
UserVO user = new UserVO();
|
||||
user.setUsername(username);
|
||||
user.setPassword(password);
|
||||
user.setState(State.Enabled);
|
||||
user.setState(State.enabled);
|
||||
user.setFirstname(firstName);
|
||||
user.setLastname(lastName);
|
||||
user.setAccountId(accountId.longValue());
|
||||
@ -1118,7 +1118,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
UserVO user = new UserVO();
|
||||
user.setUsername(userName);
|
||||
user.setPassword(password);
|
||||
user.setState(State.Enabled);
|
||||
user.setState(State.enabled);
|
||||
user.setFirstname(firstName);
|
||||
user.setLastname(lastName);
|
||||
user.setAccountId(accountId.longValue());
|
||||
@ -1249,7 +1249,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
throw new PermissionDeniedException("Failed to disable user " + userId + ", permission denied.");
|
||||
}
|
||||
|
||||
boolean success = doSetUserStatus(userId, State.Disabled);
|
||||
boolean success = doSetUserStatus(userId, State.disabled);
|
||||
if (success) {
|
||||
//user successfully disabled
|
||||
return _userAccountDao.findById(userId);
|
||||
@ -1280,7 +1280,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
throw new PermissionDeniedException("Failed to enable user " + userId + ", permission denied.");
|
||||
}
|
||||
|
||||
success = doSetUserStatus(userId, State.Enabled);
|
||||
success = doSetUserStatus(userId, State.enabled);
|
||||
|
||||
// make sure the account is enabled too
|
||||
success = (success && enableAccount(user.getAccountId()));
|
||||
@ -1319,16 +1319,16 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
|
||||
|
||||
// make sure the account is enabled too
|
||||
// if the user is either locked already or disabled already, don't change state...only lock currently enabled users
|
||||
if (user.getState().equals(State.Locked)) {
|
||||
if (user.getState().equals(State.locked)) {
|
||||
// already locked...no-op
|
||||
return _userAccountDao.findById(id);
|
||||
} else if (user.getState().equals(State.Enabled)) {
|
||||
success = doSetUserStatus(user.getId(), State.Locked);
|
||||
} else if (user.getState().equals(State.enabled)) {
|
||||
success = doSetUserStatus(user.getId(), State.locked);
|
||||
|
||||
boolean lockAccount = true;
|
||||
List<UserVO> allUsersByAccount = _userDao.listByAccount(user.getAccountId());
|
||||
for (UserVO oneUser : allUsersByAccount) {
|
||||
if (oneUser.getState().equals(State.Enabled)) {
|
||||
if (oneUser.getState().equals(State.enabled)) {
|
||||
lockAccount = false;
|
||||
break;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user