use of com.emc.storageos.model.auth.ACLEntry in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method getUsageURIsFromAclEntries.
/**
* Gets the USE URIs from the list of ACLEntry.
*
* @param aclEntries to be used to fetch the usage URIs.
* @return a set of URIs retrived from the acls.
*/
public static Set<URI> getUsageURIsFromAclEntries(List<ACLEntry> aclEntries) {
Set<URI> tenantUris = new HashSet<URI>();
if (CollectionUtils.isEmpty(aclEntries)) {
return tenantUris;
}
Iterator<ACLEntry> aclEntryIt = aclEntries.iterator();
while (aclEntryIt.hasNext()) {
ACLEntry aclEntry = aclEntryIt.next();
if (!CollectionUtils.isEmpty(aclEntry.getAces())) {
tenantUris.add(URI.create(aclEntry.getTenant()));
}
}
return tenantUris;
}
use of com.emc.storageos.model.auth.ACLEntry in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method convertToACLEntries.
/**
* Converts StringSetMap of acls into a list of ACLEntry as used by the API
*
* @param acls to be converted into the ACLEntry list.
* @return the converted ACLEntry list.
*/
public static List<ACLEntry> convertToACLEntries(StringSetMap acls) {
List<ACLEntry> assignments = new ArrayList<ACLEntry>();
if (CollectionUtils.isEmpty(acls)) {
return assignments;
}
for (Map.Entry<String, AbstractChangeTrackingSet<String>> ace : acls.entrySet()) {
PermissionsKey rowKey = new PermissionsKey();
rowKey.parseFromString(ace.getKey());
ACLEntry entry = new ACLEntry();
if (rowKey.getType().equals(PermissionsKey.Type.GROUP)) {
entry.setGroup(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.SID)) {
entry.setSubjectId(rowKey.getValue());
} else if (rowKey.getType().equals(PermissionsKey.Type.TENANT)) {
entry.setTenant(rowKey.getValue());
}
for (String priv : ace.getValue()) {
// skip owner
if (priv.equalsIgnoreCase(ACL.OWN.toString())) {
continue;
}
entry.getAces().add(priv);
}
if (!entry.getAces().isEmpty()) {
assignments.add(entry);
}
}
return assignments;
}
use of com.emc.storageos.model.auth.ACLEntry in project coprhd-controller by CoprHD.
the class BasePermissionsHelper method getUseAclEntry.
/**
* Get the USE ACLEntry for the tenant.
*
* @param tenantId to be used in the USE ACLEntry.
* @return the ACLEntry.
*/
public ACLEntry getUseAclEntry(String tenantId) {
ACLEntry aclEntry = new ACLEntry();
aclEntry.setTenant(tenantId);
aclEntry.getAces().add(ACL.USE.name());
return aclEntry;
}
use of com.emc.storageos.model.auth.ACLEntry in project coprhd-controller by CoprHD.
the class CatalogCategoryService method hasAccess.
/**
* check if specified acls permission user to access
*
* @param storageOSUser
* @param acls
* @return
*/
private boolean hasAccess(StorageOSUser storageOSUser, StringSetMap acls) {
// no acl set
if (acls == null || acls.isEmpty()) {
log.debug("acls is empty, pass");
return true;
}
// acl is not empty, check if the user is allowed.
List<ACLEntry> aclEntries = _permissionsHelper.convertToACLEntries(acls);
String username = storageOSUser.getName();
for (ACLEntry entry : aclEntries) {
if (entry.getSubjectId() != null && entry.getSubjectId().equalsIgnoreCase(username)) {
log.debug("has acls contain subjectId for current user: " + username);
return true;
} else if (entry.getGroup() != null) {
for (String group : storageOSUser.getGroups()) {
if (group.equalsIgnoreCase(entry.getGroup())) {
log.debug("has acls contain group for current user: " + entry.getGroup());
return true;
}
}
} else {
continue;
}
}
// acl is set, but user
log.debug("has acls, but current user is not in them: " + username);
return false;
}
use of com.emc.storageos.model.auth.ACLEntry in project coprhd-controller by CoprHD.
the class ACLUtils method updateACLs.
public static void updateACLs(ACLResources aclResource, URI id, List<AclEntryForm> aclEntries) {
if (aclResource != null) {
List<ACLEntry> currentAcls = aclResource.getACLs(id);
List<ACLEntry> addACLs = AclEntryForm.getAddedAcls(currentAcls, aclEntries);
List<ACLEntry> removeACLs = AclEntryForm.getRemovedAcls(currentAcls, aclEntries);
ACLAssignmentChanges aclChanges = new ACLAssignmentChanges(addACLs, removeACLs);
aclResource.updateACLs(id, aclChanges);
}
}
Aggregations