Package org.rhq.core.domain.authz

Examples of org.rhq.core.domain.authz.Role


     */
    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void addResourceGroupsToRole(Subject subject, int roleId, int[] groupIds) {
        if ((groupIds != null) && (groupIds.length > 0)) {
            Role role = entityManager.find(Role.class, roleId);
            if (role == null) {
                throw new IllegalArgumentException("Could not find role[" + roleId + "] to add resourceGroups to");
            }
            role.getResourceGroups().size(); // load them in

            for (Integer groupId : groupIds) {
                ResourceGroup group = entityManager.find(ResourceGroup.class, groupId);
                if (group == null) {
                    throw new IllegalArgumentException("Tried to add resourceGroup[" + groupId + "] to role[" + roleId
                        + "], but resourceGroup was not found.");
                }
                role.addResourceGroup(group);
            }
        }

        return;
    }
View Full Code Here


    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void removeBundleGroupsFromRole(Subject subject, int roleId, int[] bundleGroupIds) {
        if ((bundleGroupIds != null) && (bundleGroupIds.length > 0)) {
            Role role = entityManager.find(Role.class, roleId);
            if (role == null) {
                throw new IllegalArgumentException("Could not find role[" + roleId
                    + "] in order to remove BundleGroups");
            }
            role.getBundleGroups().size(); // load them in

            for (Integer bundleGroupId : bundleGroupIds) {
                BundleGroup bundleGroup = entityManager.find(BundleGroup.class, bundleGroupId);
                if (bundleGroup == null) {
                    throw new IllegalArgumentException("Tried to remove BundleGroup[" + bundleGroupId + "] from role["
                        + roleId + "], but BundleGroup was not found");
                }
                role.removeBundleGroup(bundleGroup);
            }
        }
    }
View Full Code Here

     */
    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void removeResourceGroupsFromRole(Subject subject, int roleId, int[] groupIds) {
        if ((groupIds != null) && (groupIds.length > 0)) {
            Role role = entityManager.find(Role.class, roleId);
            if (role == null) {
                throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove resourceGroups from");
            }
            role.getResourceGroups().size(); // load them in

            for (Integer groupId : groupIds) {
                ResourceGroup doomedGroup = entityManager.find(ResourceGroup.class, groupId);
                if (doomedGroup == null) {
                    throw new IllegalArgumentException("Tried to remove doomedGroup[" + groupId + "] from role["
                        + roleId + "], but subject was not found");
                }
                role.removeResourceGroup(doomedGroup);
            }
        }
    }
View Full Code Here

    }

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void setAssignedBundleGroups(Subject subject, int roleId, int[] bundleGroupIds) {
        Role role = getRole(subject, roleId);
        List<Integer> currentBundleGroups = new ArrayList<Integer>();
        for (BundleGroup group : role.getBundleGroups()) {
            currentBundleGroups.add(group.getId());
        }

        List<Integer> newBundleGroups = ArrayUtils.wrapInList(bundleGroupIds); // members needing addition
        newBundleGroups.removeAll(currentBundleGroups);
View Full Code Here

    }

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void setAssignedResourceGroups(Subject subject, int roleId, int[] groupIds) {
        Role role = getRole(subject, roleId);
        List<Integer> currentGroups = new ArrayList<Integer>();
        for (ResourceGroup group : role.getResourceGroups()) {
            currentGroups.add(group.getId());
        }

        List<Integer> newGroups = ArrayUtils.wrapInList(groupIds); // members needing addition
        newGroups.removeAll(currentGroups);
View Full Code Here

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void removeSubjectsFromRole(Subject subject, int roleId, int[] subjectIds) {
        if ((subjectIds != null) && (subjectIds.length > 0)) {
            Role role = entityManager.find(Role.class, roleId);
            if (role == null) {
                throw new IllegalArgumentException("Could not find role[" + roleId + "] to remove subjects from");
            }
            role.getSubjects().size(); // load them in

            for (Integer subjectId : subjectIds) {
                Subject doomedSubject = entityManager.find(Subject.class, subjectId);
                if (doomedSubject == null) {
                    throw new IllegalArgumentException("Tried to remove subject[" + subjectId + "] from role[" + roleId
                        + "], but subject was not found");
                }
                if (doomedSubject.getFsystem() || (authorizationManager.isSystemSuperuser(doomedSubject))) {
                    throw new PermissionException("You cannot remove user[" + doomedSubject.getName() + "] from role["
                        + roleId + "] - roles are fixed for this user");
                }
                role.removeSubject(doomedSubject);
            }
        }
    }
View Full Code Here

    @Override
    @RequiredPermission(Permission.MANAGE_SECURITY)
    public void setAssignedSubjects(Subject subject, int roleId, int[] subjectIds) {

        Role role = getRole(subject, roleId);
        List<Integer> currentSubjects = new ArrayList<Integer>();
        for (Subject currentSubject : role.getSubjects()) {
            currentSubjects.add(currentSubject.getId());
        }

        List<Integer> newSubjects = ArrayUtils.wrapInList(subjectIds); // members needing addition
        newSubjects.removeAll(currentSubjects);
View Full Code Here

                    + "] in order to remove roles");
            }
            bundleGroup.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role doomedRole = entityManager.find(Role.class, roleId);
                if (doomedRole == null) {
                    throw new IllegalArgumentException("Tried to remove role[" + roleId + "] from BundleGroup["
                        + bundleGroupId + "], but role was not found");
                }
                doomedRole.removeBundleGroup(bundleGroup);
            }
        }

        return;
    }
View Full Code Here

                throw new IllegalArgumentException("Could not find resourceGroup[" + groupId + "] to remove roles from");
            }
            group.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role doomedRole = entityManager.find(Role.class, roleId);
                if (doomedRole == null) {
                    throw new IllegalArgumentException("Tried to remove role[" + roleId + "] from resourceGroup["
                        + groupId + "], but role was not found");
                }
                group.removeRole(doomedRole);
View Full Code Here

                    + "] in order to add roles");
            }
            bundleGroup.getRoles().size(); // load them in

            for (Integer roleId : roleIds) {
                Role role = entityManager.find(Role.class, roleId);
                if (role == null) {
                    throw new IllegalArgumentException("Tried to add role[" + roleId + "] to bundleGroup["
                        + bundleGroupId + "], but role was not found");
                }
                role.addBundleGroup(bundleGroup);
            }
        }

        return;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.authz.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.