From a56f355cebc4b409840a3f2c2deea5bd0f91ab49 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 10 Jan 2013 15:33:52 -0800 Subject: [PATCH] ApiServer: get role type from account manager using account Signed-off-by: Rohit Yadav --- server/src/com/cloud/api/ApiServer.java | 29 +++---------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 1c1e8ca0e96..73871259504 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))