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);
}
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;
}
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();
}
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;
}
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));
}
}
Aggregations