Search in sources :

Example 11 with AccessPermission

use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.

the class PermissionServiceImpl method getAllSetPermissions.

@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef) {
    HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
    NodePermissionEntry nodePremissionEntry = getSetPermissions(nodeRef);
    for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries()) {
        accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
    }
    return accessPermissions;
}
Also used : AccessPermission(org.alfresco.service.cmr.security.AccessPermission) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) PermissionEntry(org.alfresco.repo.security.permissions.PermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Extend(org.alfresco.traitextender.Extend)

Example 12 with AccessPermission

use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.

the class PermissionServiceImpl method getAllSetPermissions.

@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public Set<AccessPermission> getAllSetPermissions(StoreRef storeRef) {
    HashSet<AccessPermission> accessPermissions = new HashSet<AccessPermission>();
    NodePermissionEntry nodePremissionEntry = getSetPermissions(storeRef);
    for (PermissionEntry pe : nodePremissionEntry.getPermissionEntries()) {
        accessPermissions.add(new AccessPermissionImpl(getPermission(pe.getPermissionReference()), pe.getAccessStatus(), pe.getAuthority(), pe.getPosition()));
    }
    return accessPermissions;
}
Also used : AccessPermission(org.alfresco.service.cmr.security.AccessPermission) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) PermissionEntry(org.alfresco.repo.security.permissions.PermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Extend(org.alfresco.traitextender.Extend)

Example 13 with AccessPermission

use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.

the class SiteServiceImplTest method getAllowedPermissionsMap.

/**
 * Gets the authorities and their allowed permissions for a node
 */
private Map<String, Set<String>> getAllowedPermissionsMap(NodeRef nodeRef) {
    Map<String, Set<String>> perms = new HashMap<String, Set<String>>();
    for (AccessPermission ap : permissionService.getAllSetPermissions(nodeRef)) {
        if (ap.getAccessStatus() == AccessStatus.ALLOWED) {
            Set<String> permsValue = perms.get(ap.getAuthority());
            if (permsValue == null) {
                permsValue = new HashSet<String>();
            }
            permsValue.add(ap.getPermission());
            perms.put(ap.getAuthority(), permsValue);
        }
    }
    return perms;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AccessPermission(org.alfresco.service.cmr.security.AccessPermission) FilterPropString(org.alfresco.repo.node.getchildren.FilterPropString)

Example 14 with AccessPermission

use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtension method getPermissions.

@Override
public Set<AccessPermission> getPermissions(NodeRef nodeRef) {
    PermissionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.getPermissions(nodeRef);
    } else {
        Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
        NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
        Set<AccessPermission> mergedEntries = new HashSet<>(virtualSetPermissions);
        if (nodeToAdhereTo != null) {
            Set<AccessPermission> actualSetPermissions = theTrait.getPermissions(nodeToAdhereTo);
            mergedEntries.addAll(actualSetPermissions);
        }
        return mergedEntries;
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) AccessPermission(org.alfresco.service.cmr.security.AccessPermission) PermissionServiceTrait(org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait) HashSet(java.util.HashSet)

Example 15 with AccessPermission

use of org.alfresco.service.cmr.security.AccessPermission in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtension method getAllSetPermissions.

@Override
public Set<AccessPermission> getAllSetPermissions(NodeRef nodeRef) {
    PermissionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.getAllSetPermissions(nodeRef);
    } else {
        Set<AccessPermission> virtualSetPermissions = smartStore.getAllSetPermissions(reference);
        NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
        Set<AccessPermission> actualSetPermissions;
        if (nodeToAdhereTo != null) {
            actualSetPermissions = theTrait.getAllSetPermissions(nodeToAdhereTo);
        } else {
            actualSetPermissions = Collections.emptySet();
        }
        Set<String> overridenPermissions = new HashSet<>();
        Set<AccessPermission> mergedEntries = new HashSet<>();
        for (AccessPermission permission : virtualSetPermissions) {
            overridenPermissions.add(permission.getPermission());
            mergedEntries.add(permission);
        }
        for (AccessPermission permission : actualSetPermissions) {
            if (!overridenPermissions.contains(permission.getPermission())) {
                mergedEntries.add(permission);
            }
        }
        return mergedEntries;
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) AccessPermission(org.alfresco.service.cmr.security.AccessPermission) PermissionServiceTrait(org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait) HashSet(java.util.HashSet)

Aggregations

AccessPermission (org.alfresco.service.cmr.security.AccessPermission)52 NodeRef (org.alfresco.service.cmr.repository.NodeRef)21 ArrayList (java.util.ArrayList)15 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)13 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 Test (org.junit.Test)7 Serializable (java.io.Serializable)5 List (java.util.List)5 Map (java.util.Map)5 Set (java.util.Set)5 AccessPermissionImpl (org.alfresco.repo.security.permissions.impl.AccessPermissionImpl)5 AccessStatus (org.alfresco.service.cmr.security.AccessStatus)5 QName (org.alfresco.service.namespace.QName)5 LinkedHashSet (java.util.LinkedHashSet)4 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)4 FacesContext (javax.faces.context.FacesContext)3 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)3 FilterPropString (org.alfresco.repo.node.getchildren.FilterPropString)3 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)3