use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class TestPermissionPopulator method populate.
/**
* Populate entity type permissions for the current user.
*/
@Transactional
public void populate(Map<String, EntityTypePermission> entityTypePermissionMap, String username) {
Sid sid = new PrincipalSid(username);
runAsSystem(() -> entityTypePermissionMap.forEach((entityTypeId, permission) -> {
MutableAcl acl = (MutableAcl) mutableAclService.readAclById(new EntityTypeIdentity(entityTypeId));
acl.insertAce(acl.getEntries().size(), getCumulativePermission(permission), sid, true);
mutableAclService.updateAcl(acl);
}));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class VcfImportServiceIT method populateUserPermissions.
private void populateUserPermissions() {
Sid sid = new PrincipalSid(SecurityUtils.getCurrentUsername());
Map<String, EntityTypePermission> entityTypePermissionMap = new HashMap<>();
entityTypePermissionMap.put("sys_md_Package", READ);
entityTypePermissionMap.put("sys_md_EntityType", READ);
entityTypePermissionMap.put("sys_md_Attribute", READ);
entityTypePermissionMap.put("sys_dec_DecoratorConfiguration", READ);
runAsSystem(() -> entityTypePermissionMap.forEach((entityTypeId, permission) -> {
MutableAcl acl = (MutableAcl) mutableAclService.readAclById(new EntityTypeIdentity(entityTypeId));
acl.insertAce(acl.getEntries().size(), getCumulativePermission(permission), sid, true);
mutableAclService.updateAcl(acl);
}));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class MolgenisPermissionControllerTest method hasReadPermissionTrue.
@Test
public void hasReadPermissionTrue() {
String entityTypeId = "entity";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.READ)).thenReturn(true);
assertTrue(molgenisPermissionController.hasReadPermission(entityTypeId));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class MolgenisPermissionControllerTest method hasWritePermissionTrue.
@Test
public void hasWritePermissionTrue() {
String entityTypeId = "entity";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.WRITE)).thenReturn(true);
assertTrue(molgenisPermissionController.hasWritePermission(entityTypeId));
}
use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.
the class MolgenisPermissionControllerTest method hasReadPermissionFalse.
@Test
public void hasReadPermissionFalse() {
String entityTypeId = "entity";
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.READ)).thenReturn(false);
assertFalse(molgenisPermissionController.hasReadPermission(entityTypeId));
}
Aggregations