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