Search in sources :

Example 1 with SimpleNodePermissionEntry

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

use of org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry 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)

Example 3 with SimpleNodePermissionEntry

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

the class AbstractPermissionsDaoComponentImpl method createSimpleNodePermissionEntry.

private SimpleNodePermissionEntry createSimpleNodePermissionEntry(StoreRef storeRef) {
    Acl acl = getACLDAO(storeRef).getAccessControlList(storeRef);
    if (acl == null) {
        // there isn't an access control list for the node - spoof a null one
        SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, true, Collections.<SimplePermissionEntry>emptyList());
        return snpe;
    } else {
        AccessControlList info = aclDaoComponent.getAccessControlList(acl.getId());
        ArrayList<SimplePermissionEntry> spes = new ArrayList<SimplePermissionEntry>(info.getEntries().size());
        for (AccessControlEntry entry : info.getEntries()) {
            SimplePermissionEntry spe = new SimplePermissionEntry(null, entry.getPermission(), entry.getAuthority(), entry.getAccessStatus(), entry.getPosition());
            spes.add(spe);
        }
        SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, acl.getInherits(), spes);
        return snpe;
    }
}
Also used : AccessControlList(org.alfresco.repo.security.permissions.AccessControlList) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) ArrayList(java.util.ArrayList) SimplePermissionEntry(org.alfresco.repo.security.permissions.impl.SimplePermissionEntry) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry) AccessControlEntry(org.alfresco.repo.security.permissions.AccessControlEntry)

Example 4 with SimpleNodePermissionEntry

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

the class AbstractPermissionsDaoComponentImpl method createSimpleNodePermissionEntry.

// Utility methods to create simple detached objects for the outside world
// We do not pass out the hibernate objects
private SimpleNodePermissionEntry createSimpleNodePermissionEntry(NodeRef nodeRef) {
    Acl acl = getACLDAO(nodeRef).getAccessControlList(nodeRef);
    if (acl == null) {
        // there isn't an access control list for the node - spoof a null one
        SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(nodeRef, true, Collections.<SimplePermissionEntry>emptyList());
        return snpe;
    } else {
        AccessControlList info = aclDaoComponent.getAccessControlList(acl.getId());
        SimpleNodePermissionEntry cached = info.getCachedSimpleNodePermissionEntry();
        if (cached != null) {
            return cached;
        }
        ArrayList<SimplePermissionEntry> spes = new ArrayList<SimplePermissionEntry>(info.getEntries().size());
        for (AccessControlEntry entry : info.getEntries()) {
            SimplePermissionEntry spe = new SimplePermissionEntry(nodeRef, entry.getPermission(), entry.getAuthority(), entry.getAccessStatus(), entry.getPosition());
            spes.add(spe);
        }
        SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(nodeRef, acl.getInherits(), spes);
        info.setCachedSimpleNodePermissionEntry(snpe);
        return snpe;
    }
}
Also used : AccessControlList(org.alfresco.repo.security.permissions.AccessControlList) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) ArrayList(java.util.ArrayList) SimplePermissionEntry(org.alfresco.repo.security.permissions.impl.SimplePermissionEntry) SimpleAccessControlEntry(org.alfresco.repo.security.permissions.SimpleAccessControlEntry) AccessControlEntry(org.alfresco.repo.security.permissions.AccessControlEntry)

Example 5 with SimpleNodePermissionEntry

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

the class AbstractPermissionsDaoComponentImpl method getPermissions.

public NodePermissionEntry getPermissions(StoreRef storeRef) {
    // Create the object if it is not found.
    // Null objects are not cached in hibernate
    // If the object does not exist it will repeatedly query to check its
    // non existence.
    NodePermissionEntry npe = null;
    Acl acl = null;
    try {
        acl = getAccessControlList(storeRef);
    } catch (InvalidNodeRefException e) {
    // Do nothing.
    }
    if (acl == null) {
        // there isn't an access control list for the node - spoof a null one
        SimpleNodePermissionEntry snpe = new SimpleNodePermissionEntry(null, true, Collections.<SimplePermissionEntry>emptyList());
        npe = snpe;
    } else {
        npe = createSimpleNodePermissionEntry(storeRef);
    }
    return npe;
}
Also used : SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) InvalidNodeRefException(org.alfresco.service.cmr.repository.InvalidNodeRefException) SimpleNodePermissionEntry(org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry) NodePermissionEntry(org.alfresco.repo.security.permissions.NodePermissionEntry)

Aggregations

SimpleNodePermissionEntry (org.alfresco.repo.security.permissions.impl.SimpleNodePermissionEntry)6 NodePermissionEntry (org.alfresco.repo.security.permissions.NodePermissionEntry)4 SimplePermissionEntry (org.alfresco.repo.security.permissions.impl.SimplePermissionEntry)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 AccessControlEntry (org.alfresco.repo.security.permissions.AccessControlEntry)2 AccessControlList (org.alfresco.repo.security.permissions.AccessControlList)2 PermissionEntry (org.alfresco.repo.security.permissions.PermissionEntry)2 PermissionReference (org.alfresco.repo.security.permissions.PermissionReference)2 SimpleAccessControlEntry (org.alfresco.repo.security.permissions.SimpleAccessControlEntry)2 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)2 NodeRef (org.alfresco.service.cmr.repository.NodeRef)2 HashSet (java.util.HashSet)1 PermissionServiceTrait (org.alfresco.repo.security.permissions.impl.traitextender.PermissionServiceTrait)1 Reference (org.alfresco.repo.virtual.ref.Reference)1 QName (org.alfresco.service.namespace.QName)1