Search in sources :

Example 16 with RoleAssignmentEntry

use of com.emc.storageos.model.auth.RoleAssignmentEntry in project coprhd-controller by CoprHD.

the class PermissionsHelper method convertToRoleAssignments.

/**
 * Converts StringSetMap of permissions into a list of assignment entries as used by the API
 *
 * @param roleAssignments
 * @param forZone
 * @return
 */
public ArrayList<RoleAssignmentEntry> convertToRoleAssignments(StringSetMap roleAssignments, boolean forZone) {
    ArrayList<RoleAssignmentEntry> assignments = new ArrayList<RoleAssignmentEntry>();
    if (roleAssignments != null && !roleAssignments.isEmpty()) {
        for (Map.Entry<String, AbstractChangeTrackingSet<String>> roleAssignment : roleAssignments.entrySet()) {
            PermissionsKey rowKey = new PermissionsKey();
            rowKey.parseFromString(roleAssignment.getKey());
            RoleAssignmentEntry entry = new RoleAssignmentEntry();
            if (rowKey.getType().equals(PermissionsKey.Type.GROUP)) {
                entry.setGroup(rowKey.getValue());
            } else if (rowKey.getType().equals(PermissionsKey.Type.SID)) {
                entry.setSubjectId(rowKey.getValue());
            }
            for (String role : roleAssignment.getValue()) {
                if ((forZone && isRoleZoneLevel(role)) || (!forZone && isRoleTenantLevel(role))) {
                    entry.getRoles().add(role);
                }
            }
            if (!entry.getRoles().isEmpty()) {
                assignments.add(entry);
            }
        }
    }
    return assignments;
}
Also used : PermissionsKey(com.emc.storageos.security.authorization.PermissionsKey) RoleAssignmentEntry(com.emc.storageos.model.auth.RoleAssignmentEntry) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

RoleAssignmentEntry (com.emc.storageos.model.auth.RoleAssignmentEntry)16 RoleAssignmentChanges (com.emc.storageos.model.auth.RoleAssignmentChanges)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)5 RoleAssignmentUtils.createRoleAssignmentEntry (util.RoleAssignmentUtils.createRoleAssignmentEntry)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 AuthnUpdateParam (com.emc.storageos.model.auth.AuthnUpdateParam)2 ProjectParam (com.emc.storageos.model.project.ProjectParam)2 TenantResponse (com.emc.storageos.model.tenant.TenantResponse)2 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)2 Restrictions (controllers.deadbolt.Restrictions)2 FlashException (controllers.util.FlashException)2 RoleAssignmentType (models.RoleAssignmentType)2 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)1 RoleAssignments (com.emc.storageos.model.auth.RoleAssignments)1 TenantCreateParam (com.emc.storageos.model.tenant.TenantCreateParam)1 TenantOrgList (com.emc.storageos.model.tenant.TenantOrgList)1 TenantOrgRestRep (com.emc.storageos.model.tenant.TenantOrgRestRep)1 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)1 UserMappingAttributeParam (com.emc.storageos.model.tenant.UserMappingAttributeParam)1