use of com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItem in project xp by enonic.
the class AccessControlListStoreDocumentFactory method create.
static List<IndexItem> create(final AccessControlList accessControlList) {
final List<IndexItem> aclStoreDocumentItems = new ArrayList<>();
for (final AccessControlEntry entry : accessControlList) {
final Iterable<Permission> allowedPermissions = entry.getAllowedPermissions();
final PrincipalKey principalKey = entry.getPrincipal();
for (final Permission permission : allowedPermissions) {
aclStoreDocumentItems.add(new IndexItemString(getPathForPermission(permission), principalKey.toString()));
}
}
return aclStoreDocumentItems;
}
use of com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItem 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.repo.impl.elasticsearch.document.indexitem.IndexItem 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.repo.impl.elasticsearch.document.indexitem.IndexItem 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