use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class ApplyNodePermissionsCommand method applyPermissionsToChildren.
private void applyPermissionsToChildren(final Node parent) {
final AccessControlList parentPermissions = parent.getPermissions();
final FindNodesByParentParams findByParentParams = FindNodesByParentParams.create().parentPath(parent.path()).size(NodeSearchService.GET_ALL_SIZE_FLAG).build();
final FindNodesByParentResult result = doFindNodesByParent(findByParentParams);
final Nodes children = GetNodesByIdsCommand.create(this).ids(result.getNodeIds()).build().execute();
for (Node child : children) {
applyPermissions(parentPermissions, child);
}
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class ApplyNodePermissionsCommand method storePermissions.
private Node storePermissions(final AccessControlList permissions, final Node node) {
final Node updatedNode;
final boolean isParent = node.id().equals(params.getNodeId());
if (params.isOverwriteChildPermissions() || node.inheritsPermissions() || isParent) {
updatedNode = createUpdatedNode(node, permissions, !isParent || params.isInheritPermissions());
} else {
final AccessControlList mergedPermissions = mergingStrategy.mergePermissions(node.getPermissions(), permissions);
updatedNode = createUpdatedNode(node, mergedPermissions, false);
}
final Node result = StoreNodeCommand.create(this).node(updatedNode).updateMetadataOnly(false).build().execute();
return result;
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class AccessControlListIndexDocumentFactoryTest method single_user.
@Test
public void single_user() throws Exception {
final AccessControlList acl = AccessControlList.create().add(AccessControlEntry.create().allow(Permission.READ).principal(PrincipalKey.from("user:myidprovider:rmy")).build()).build();
final List<IndexItem> aclStoreDocumentItems = AccessControlListStoreDocumentFactory.create(acl);
assertEquals(1, aclStoreDocumentItems.size());
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class AccessControlListIndexDocumentFactoryTest method multiple_user.
@Test
public void multiple_user() throws Exception {
final AccessControlList acl = AccessControlList.create().add(AccessControlEntry.create().allow(Permission.READ).principal(PrincipalKey.from("user:myidprovider:rmy")).build()).add(AccessControlEntry.create().allow(Permission.READ).principal(PrincipalKey.from("user:myidprovider:tsi")).build()).add(AccessControlEntry.create().allow(Permission.READ).allow(Permission.DELETE).principal(PrincipalKey.from("user:myidprovider:aro")).build()).add(AccessControlEntry.create().allow(Permission.DELETE).principal(PrincipalKey.from("user:myidprovider:srs")).build()).build();
final List<IndexItem> aclStoreDocumentItems = AccessControlListStoreDocumentFactory.create(acl);
assertEquals(5, aclStoreDocumentItems.size());
}
use of com.enonic.xp.security.acl.AccessControlList in project xp by enonic.
the class AccessControlListIndexDocumentFactoryTest method single_user_all_permissions.
@Test
public void single_user_all_permissions() throws Exception {
final AccessControlList acl = AccessControlList.create().add(AccessControlEntry.create().allow(Permission.READ).allow(Permission.PUBLISH).allow(Permission.WRITE_PERMISSIONS).allow(Permission.READ_PERMISSIONS).allow(Permission.MODIFY).allow(Permission.CREATE).allow(Permission.DELETE).principal(PrincipalKey.from("user:myidprovider:rmy")).build()).build();
final List<IndexItem> aclStoreDocumentItems = AccessControlListStoreDocumentFactory.create(acl);
assertEquals(7, aclStoreDocumentItems.size());
}
Aggregations