Search in sources :

Example 1 with NodePermissionEntry

use of org.alfresco.repo.security.permissions.NodePermissionEntry 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 2 with NodePermissionEntry

use of org.alfresco.repo.security.permissions.NodePermissionEntry 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 3 with NodePermissionEntry

use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtension method getSetPermissions.

@Override
public NodePermissionEntry getSetPermissions(NodeRef nodeRef) {
    PermissionServiceTrait theTrait = getTrait();
    Reference reference = Reference.fromNodeRef(nodeRef);
    if (reference == null) {
        return theTrait.getSetPermissions(nodeRef);
    } else {
        NodePermissionEntry virtualSetPermissions = smartStore.getSetPermissions(reference);
        NodeRef nodeToAdhereTo = establishPermisisonAdherence(reference);
        List<? extends PermissionEntry> actualPermissionEntries;
        boolean inheritPermissions = false;
        if (nodeToAdhereTo != null) {
            NodePermissionEntry actualSetPermissions = theTrait.getSetPermissions(nodeToAdhereTo);
            actualPermissionEntries = actualSetPermissions.getPermissionEntries();
            inheritPermissions = actualSetPermissions.inheritPermissions();
        } else {
            actualPermissionEntries = Collections.emptyList();
            inheritPermissions = false;
        }
        List<PermissionEntry> mergedEntries = new LinkedList<>();
        List<? extends PermissionEntry> virtualPermissionEntries = virtualSetPermissions.getPermissionEntries();
        Set<QName> overridenPermissions = new HashSet<>();
        for (PermissionEntry permissionEntry : virtualPermissionEntries) {
            overridenPermissions.add(permissionEntry.getPermissionReference().getQName());
            mergedEntries.add(permissionEntry);
        }
        for (PermissionEntry permissionEntry : actualPermissionEntries) {
            if (!overridenPermissions.contains(permissionEntry.getPermissionReference().getQName())) {
                mergedEntries.add(permissionEntry);
            }
        }
        return new SimpleNodePermissionEntry(nodeRef, inheritPermissions, mergedEntries);
    }
}
Also used : PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) Reference(org.alfresco.repo.virtual.ref.Reference) QName(org.alfresco.service.namespace.QName) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) PermissionServiceTrait(org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait) LinkedList(java.util.LinkedList) NodeRef(org.alfresco.service.cmr.repository.NodeRef) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) PermissionEntry(org.alfresco.repo.security.permissions.PermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) HashSet(java.util.HashSet)

Example 4 with NodePermissionEntry

use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.

the class VirtualPermissionServiceExtensionTest method testGetSetPermissions.

@Test
public void testGetSetPermissions() throws Exception {
    setUpTestPermissions();
    NodePermissionEntry vf1SetPermissions = permissionService.getSetPermissions(this.virtualFolder1NodeRef);
    assertEquals(virtualFolder1NodeRef, vf1SetPermissions.getNodeRef());
    List<? extends PermissionEntry> vf1Entries = vf1SetPermissions.getPermissionEntries();
    assertUniquePermission(PermissionService.DELETE, AccessStatus.ALLOWED, user1, vf1Entries);
    assertUniquePermission(PermissionService.CREATE_CHILDREN, AccessStatus.DENIED, user1, vf1Entries);
    NodePermissionEntry node2SetPermissions = permissionService.getSetPermissions(vf1Node2);
    assertEquals(vf1Node2, node2SetPermissions.getNodeRef());
    List<? extends PermissionEntry> node2Entries = node2SetPermissions.getPermissionEntries();
    assertUniquePermission(PermissionService.DELETE, AccessStatus.DENIED, PermissionService.ALL_AUTHORITIES, node2Entries);
    assertUniquePermission(PermissionService.CREATE_CHILDREN, AccessStatus.ALLOWED, PermissionService.ALL_AUTHORITIES, node2Entries);
}
Also used : NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 5 with NodePermissionEntry

use of org.alfresco.repo.security.permissions.NodePermissionEntry in project alfresco-repository by Alfresco.

the class GetSetPermissionsMethod method execute.

private NodePermissionEntry execute(Reference reference, Set<String> toAllow, Set<String> toDeny) {
    NodeRef rNodeRef = reference.toNodeRef();
    List<PermissionEntry> permissions = new LinkedList<>();
    for (String permission : toAllow) {
        PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
        permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.ALLOWED));
    }
    for (String permission : toDeny) {
        PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
        permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.DENIED));
    }
    return new SimpleNodePermissionEntry(rNodeRef, false, permissions);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) PermissionReference(org.alfresco.repo.security.permissions.PermissionReference) PermissionEntry(org.alfresco.repo.security.permissions.PermissionEntry) SimplePermissionEntry(org.alfresco.repo.security.permissions.impl.SimplePermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) SimplePermissionEntry(org.alfresco.repo.security.permissions.impl.SimplePermissionEntry) LinkedList(java.util.LinkedList)

Aggregations

NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)9 PermissionEntry (org.alfresco.repo.security.permissions.PermissionEntry)5 SimpleNodePermissionEntry (org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 HashSet (java.util.HashSet)3 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)3 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 SimplePermissionEntry (org.alfresco.repo.security.permissions.impl.SimplePermissionEntry)2 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)2 AccessPermission (org.alfresco.service.cmr.security.AccessPermission)2 Extend (org.alfresco.traitextender.Extend)2 ArrayList (java.util.ArrayList)1 SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)1 AclChange (org.alfresco.repo.security.permissions.impl.AclChange)1 PermissionServiceTrait (org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait)1 VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 QName (org.alfresco.service.namespace.QName)1 Test (org.junit.Test)1