diff --git a/services/iam/plugin/src/org/apache/cloudstack/acl/RoleBasedEntityAccessChecker.java b/services/iam/plugin/src/org/apache/cloudstack/acl/RoleBasedEntityAccessChecker.java index e180000ee5b..040a3e54552 100644 --- a/services/iam/plugin/src/org/apache/cloudstack/acl/RoleBasedEntityAccessChecker.java +++ b/services/iam/plugin/src/org/apache/cloudstack/acl/RoleBasedEntityAccessChecker.java @@ -24,7 +24,6 @@ import javax.inject.Inject; import org.apache.log4j.Logger; -import org.apache.cloudstack.acl.api.AclApiService; import org.apache.cloudstack.iam.api.AclPolicy; import org.apache.cloudstack.iam.api.AclPolicyPermission; import org.apache.cloudstack.iam.api.IAMService; @@ -41,8 +40,6 @@ public class RoleBasedEntityAccessChecker extends DomainChecker implements Secur @Inject AccountService _accountService; - @Inject - AclApiService _aclService; @Inject DomainDao _domainDao; @@ -67,7 +64,7 @@ public class RoleBasedEntityAccessChecker extends DomainChecker implements Secur } // get all Policies of this caller w.r.t the entity - List policies = _aclService.getEffectivePolicies(caller, entity); + List policies = getEffectivePolicies(caller, entity); HashMap policyPermissionMap = new HashMap(); for (AclPolicy policy : policies) { @@ -120,4 +117,18 @@ public class RoleBasedEntityAccessChecker extends DomainChecker implements Secur return false; } + + private List getEffectivePolicies(Account caller, ControlledEntity entity) { + + // Get the static Policies of the Caller + List policies = _iamSrv.listAclPolicies(caller.getId()); + + // add any dynamic policies w.r.t the entity + if (caller.getId() == entity.getAccountId()) { + // The caller owns the entity + policies.add(_iamSrv.getResourceOwnerPolicy()); + } + + return policies; + } } diff --git a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiService.java b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiService.java index 12ecf8b3d10..3d7bb3c32ce 100644 --- a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiService.java +++ b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiService.java @@ -18,7 +18,6 @@ package org.apache.cloudstack.acl.api; import java.util.List; -import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.PermissionScope; import org.apache.cloudstack.acl.api.response.AclGroupResponse; import org.apache.cloudstack.acl.api.response.AclPolicyResponse; @@ -60,8 +59,6 @@ public interface AclApiService { AclPolicyPermission getAclPolicyPermission(long accountId, String entityType, String action); - List getEffectivePolicies(Account caller, ControlledEntity entity); - /* Response Generation */ AclPolicyResponse createAclPolicyResponse(AclPolicy policy); diff --git a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java index b117d0c5671..3fca5d5e8e3 100644 --- a/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java +++ b/services/iam/plugin/src/org/apache/cloudstack/acl/api/AclApiServiceImpl.java @@ -25,7 +25,6 @@ import javax.inject.Inject; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.AclEntityType; -import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.PermissionScope; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.acl.api.response.AclGroupResponse; @@ -191,21 +190,6 @@ public class AclApiServiceImpl extends ManagerBase implements AclApiService, Man } - @Override - public List getEffectivePolicies(Account caller, ControlledEntity entity) { - - // Get the static Policies of the Caller - List policies = _iamSrv.listAclPolicies(caller.getId()); - - // add any dynamic policies w.r.t the entity - if (caller.getId() == entity.getAccountId()) { - // The caller owns the entity - policies.add(_iamSrv.getResourceOwnerPolicy()); - } - - return policies; - } - @Override public AclPolicyResponse createAclPolicyResponse(AclPolicy policy) { AclPolicyResponse response = new AclPolicyResponse(); diff --git a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java index e6fcdcdca4f..98a0793e516 100644 --- a/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java +++ b/services/iam/server/src/org/apache/cloudstack/iam/server/IAMServiceImpl.java @@ -131,6 +131,7 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { return true; } + @SuppressWarnings("unchecked") @Override public List listAclGroups(long accountId) { @@ -145,9 +146,9 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { sb.and("ids", sb.entity().getId(), Op.IN); SearchCriteria sc = sb.create(); sc.setParameters("ids", groupIds.toArray(new Object[groupIds.size()])); - List groups = _aclGroupDao.search(sc, null); - - return new ArrayList(groups); + @SuppressWarnings("rawtypes") + List groups = _aclGroupDao.search(sc, null); + return groups; } @DB @@ -324,6 +325,7 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { } + @SuppressWarnings("unchecked") @Override public List listAclPolicies(long accountId) { @@ -345,11 +347,13 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { sb.and("ids", sb.entity().getId(), Op.IN); SearchCriteria sc = sb.create(); sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()])); - List policies = _aclPolicyDao.customSearch(sc, null); + @SuppressWarnings("rawtypes") + List policies = _aclPolicyDao.customSearch(sc, null); + return policies; - return new ArrayList(policies); } + @SuppressWarnings("unchecked") @Override public List listAclPoliciesByGroup(long groupId) { List policyGrpMap = _aclGroupPolicyMapDao.listByGroupId(groupId); @@ -366,11 +370,13 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { sb.and("ids", sb.entity().getId(), Op.IN); SearchCriteria sc = sb.create(); sc.setParameters("ids", policyIds.toArray(new Object[policyIds.size()])); - List policies = _aclPolicyDao.customSearch(sc, null); + @SuppressWarnings("rawtypes") + List policies = _aclPolicyDao.customSearch(sc, null); - return new ArrayList(policies); + return policies; } + @SuppressWarnings("unchecked") @Override public Pair, Integer> listAclPolicies(Long aclPolicyId, String aclPolicyName, String path, Long startIndex, Long pageSize) { @@ -401,7 +407,9 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { sc.setParameters("path", path + "%"); Pair, Integer> policies = _aclPolicyDao.searchAndCount(sc, searchFilter); - return new Pair, Integer>(new ArrayList(policies.first()), policies.second()); + @SuppressWarnings("rawtypes") + List policyList = policies.first(); + return new Pair, Integer>(policyList, policies.second()); } @DB @@ -649,35 +657,35 @@ public class IAMServiceImpl extends ManagerBase implements IAMService, Manager { } @Override + @SuppressWarnings("unchecked") public List listPolicyPermissions(long policyId) { - List pp = _policyPermissionDao.listByPolicy(policyId); - List pl = new ArrayList(); - pl.addAll(pp); - return pl; + @SuppressWarnings("rawtypes") + List pp = _policyPermissionDao.listByPolicy(policyId); + return pp; } + @SuppressWarnings("unchecked") @Override public List listPolicyPermissionsByScope(long policyId, String action, String scope) { - List pp = _policyPermissionDao.listGrantedByActionAndScope(policyId, action, scope); - List pl = new ArrayList(); - pl.addAll(pp); - return pl; + @SuppressWarnings("rawtypes") + List pp = _policyPermissionDao.listGrantedByActionAndScope(policyId, action, scope); + return pp; } + @SuppressWarnings("unchecked") @Override public List listPolicyPermissionByEntityType(long policyId, String action, String entityType) { - List pp = _policyPermissionDao.listByPolicyActionAndEntity(policyId, action, entityType); - List pl = new ArrayList(); - pl.addAll(pp); - return pl; + @SuppressWarnings("rawtypes") + List pp = _policyPermissionDao.listByPolicyActionAndEntity(policyId, action, entityType); + return pp; } + @SuppressWarnings("unchecked") @Override public List listPolicyPermissionByAccessType(long policyId, String accessType, String entityType, String action) { - List pp = _policyPermissionDao.listByPolicyAccessAndEntity(policyId, accessType, entityType, action); - List pl = new ArrayList(); - pl.addAll(pp); - return pl; + @SuppressWarnings("rawtypes") + List pp = _policyPermissionDao.listByPolicyAccessAndEntity(policyId, accessType, entityType, action); + return pp; } @Override