You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2013/01/12 00:51:03 UTC
[6/32] git commit: ApiServer: get role type from account manager
using account
ApiServer: get role type from account manager using account
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a56f355c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a56f355c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a56f355c
Branch: refs/heads/api_limit
Commit: a56f355cebc4b409840a3f2c2deea5bd0f91ab49
Parents: 1425736
Author: Rohit Yadav <bh...@apache.org>
Authored: Thu Jan 10 15:33:52 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Jan 10 15:55:01 2013 -0800
----------------------------------------------------------------------
server/src/com/cloud/api/ApiServer.java | 29 ++-----------------------
1 files changed, 3 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a56f355c/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index 1c1e8ca..7387125 100755
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -790,37 +790,14 @@ public class ApiServer implements HttpRequestHandler {
return true;
}
- private boolean isCommandAvailable(User user, String commandName) {
+ private boolean isCommandAvailable(User user, String commandName)
+ throws PermissionDeniedException {
if (user == null) {
return false;
}
Account account = _accountMgr.getAccount(user.getAccountId());
- if (account == null) {
- return false;
- }
-
- RoleType roleType = RoleType.Unknown;
- short accountType = account.getType();
-
- // Account type to role type translation
- switch (accountType) {
- case Account.ACCOUNT_TYPE_ADMIN:
- roleType = RoleType.Admin;
- break;
- case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
- roleType = RoleType.DomainAdmin;
- break;
- case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
- roleType = RoleType.ResourceAdmin;
- break;
- case Account.ACCOUNT_TYPE_NORMAL:
- roleType = RoleType.User;
- break;
- default:
- return false;
- }
-
+ RoleType roleType = _accountMgr.getRoleType(account);
for (APIAccessChecker apiChecker : _apiAccessCheckers) {
// Fail the checking if any checker fails to verify
if (!apiChecker.canAccessAPI(roleType, commandName))