Search in sources :

Example 6 with ACLEntry

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

the class VCenters method getVcenterTenantOptions.

public static void getVcenterTenantOptions(String id) {
    List<TenantOrgRestRep> vCenterTenantOptions = new ArrayList<TenantOrgRestRep>();
    if (StringUtils.isBlank(id) || id.equalsIgnoreCase("null")) {
        renderJSON(vCenterTenantOptions);
        return;
    }
    List<ACLEntry> vcenterAcls = VCenterUtils.getAcl(uri(id));
    if (CollectionUtils.isEmpty(vcenterAcls)) {
        renderJSON(vCenterTenantOptions);
        return;
    }
    addNoneTenantOption(id, vCenterTenantOptions);
    Iterator<ACLEntry> aclEntryIterator = vcenterAcls.iterator();
    while (aclEntryIterator.hasNext()) {
        ACLEntry aclEntry = aclEntryIterator.next();
        if (aclEntry == null) {
            continue;
        }
        TenantOrgRestRep tenantOrgRestRep = TenantUtils.getTenant(aclEntry.getTenant());
        if (tenantOrgRestRep != null) {
            vCenterTenantOptions.add(tenantOrgRestRep);
        }
    }
    renderJSON(vCenterTenantOptions);
}
Also used : ACLEntry(com.emc.storageos.model.auth.ACLEntry) ArrayList(java.util.ArrayList) TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep)

Example 7 with ACLEntry

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

the class ACLUpdateBuilder method createTenantACLs.

private Set<ACLEntry> createTenantACLs(Set<String> tenants) {
    Set<ACLEntry> entries = Sets.newHashSet();
    for (String tenant : tenants) {
        ACLEntry entry = new ACLEntry();
        entry.setTenant(tenant);
        entry.getAces().add(ACLs.USE);
        entries.add(entry);
    }
    return entries;
}
Also used : ACLEntry(com.emc.storageos.model.auth.ACLEntry)

Example 8 with ACLEntry

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

the class VirtualPoolCommonForm method loadTenantACLs.

/**
 * Loads the tenant ACL information from the provided ACLResources.
 *
 * @param resources
 *            the resources from which to load the ACLs.
 */
protected void loadTenantACLs(ACLResources resources) {
    tenants = Lists.newArrayList();
    URI virtualPoolId = ResourceUtils.uri(id);
    if (virtualPoolId != null) {
        for (ACLEntry acl : resources.getACLs(virtualPoolId)) {
            if (StringUtils.isNotBlank(acl.getTenant())) {
                tenants.add(acl.getTenant());
            }
        }
    }
    enableTenants = !tenants.isEmpty();
}
Also used : ACLEntry(com.emc.storageos.model.auth.ACLEntry) URI(java.net.URI)

Example 9 with ACLEntry

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

the class AclEntryForm method getRemovedAcls.

public static List<ACLEntry> getRemovedAcls(List<ACLEntry> currentAcls, List<AclEntryForm> aclEntries) {
    List<ACLEntry> removed = Lists.newArrayList();
    for (ACLEntry currentAcl : currentAcls) {
        boolean foundAclEntry = false;
        for (AclEntryForm aclEntryForm : aclEntries) {
            if (aclEntryForm != null) {
                ACLEntry aclParamEntry = aclEntryForm.createACLEntry();
                if (isSameACLEntry(aclParamEntry, currentAcl)) {
                    foundAclEntry = true;
                    for (String acl : currentAcl.getAces()) {
                        if (aclParamEntry.getAces().contains(acl) == false) {
                            ACLEntry removedACLEntry = new ACLEntry();
                            removedACLEntry.setTenant(currentAcl.getTenant());
                            removedACLEntry.setGroup(currentAcl.getGroup());
                            removedACLEntry.setSubjectId(currentAcl.getSubjectId());
                            removedACLEntry.getAces().add(acl);
                            removed.add(removedACLEntry);
                        }
                    }
                }
            }
        }
        if (foundAclEntry == false) {
            for (String acl : currentAcl.getAces()) {
                ACLEntry removedACLEntry = new ACLEntry();
                removedACLEntry.setTenant(currentAcl.getTenant());
                removedACLEntry.setGroup(currentAcl.getGroup());
                removedACLEntry.setSubjectId(currentAcl.getSubjectId());
                removedACLEntry.getAces().add(acl);
                removed.add(removedACLEntry);
            }
        }
    }
    return removed;
}
Also used : ACLEntry(com.emc.storageos.model.auth.ACLEntry)

Example 10 with ACLEntry

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

the class Projects method saveProjectACLs.

@Util
private static void saveProjectACLs(String projectId, List<AclEntryForm> aclEntries) {
    List<ACLEntry> currentProjectAcls = ProjectUtils.getACLs(projectId);
    ACLAssignmentChanges changes = new ACLAssignmentChanges();
    changes.getAdd().addAll(AclEntryForm.getAddedAcls(currentProjectAcls, aclEntries));
    changes.getRemove().addAll(AclEntryForm.getRemovedAcls(currentProjectAcls, aclEntries));
    try {
        ProjectUtils.updateACLs(projectId, changes);
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Project ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("projects.updateProjectACLs.failed", errorDesc));
    }
}
Also used : ACLAssignmentChanges(com.emc.storageos.model.auth.ACLAssignmentChanges) ACLEntry(com.emc.storageos.model.auth.ACLEntry) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Util(play.mvc.Util)

Aggregations

ACLEntry (com.emc.storageos.model.auth.ACLEntry)21 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)6 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 URI (java.net.URI)4 ArrayList (java.util.ArrayList)4 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)3 HashSet (java.util.HashSet)3 ACLAssignments (com.emc.storageos.model.auth.ACLAssignments)2 ProjectParam (com.emc.storageos.model.project.ProjectParam)2 BlockVirtualPoolParam (com.emc.storageos.model.vpool.BlockVirtualPoolParam)2 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)2 FileVirtualPoolParam (com.emc.storageos.model.vpool.FileVirtualPoolParam)2 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 TagAssignment (com.emc.storageos.model.TagAssignment)1 ProjectElement (com.emc.storageos.model.project.ProjectElement)1 ProjectUpdateParam (com.emc.storageos.model.project.ProjectUpdateParam)1