use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class OntologyImportServiceIT method populateUserPermissions.
private void populateUserPermissions() {
Sid sid = new PrincipalSid(SecurityUtils.getCurrentUsername());
Map<String, EntityTypePermission> entityTypePermissionMap = new HashMap<>();
entityTypePermissionMap.put("sys_ont_OntologyTermDynamicAnnotation", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTermNodePath", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTermSynonym", WRITE);
entityTypePermissionMap.put("sys_ont_Ontology", WRITE);
entityTypePermissionMap.put("sys_ont_OntologyTerm", WRITE);
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.springframework.security.acls.model.MutableAcl 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.springframework.security.acls.model.MutableAcl 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.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testUpdate.
@Test
public void testUpdate() {
Package pack = mock(Package.class);
Package parent = mock(Package.class);
when(pack.getId()).thenReturn("1");
when(parent.getId()).thenReturn("2");
when(pack.getParent()).thenReturn(parent);
MutableAcl acl = mock(MutableAcl.class);
MutableAcl parentAcl = mock(MutableAcl.class);
when(mutableAclService.readAclById(any())).thenAnswer(invocation -> {
Object argument = invocation.getArguments()[0];
if (argument.equals(new PackageIdentity("1"))) {
return acl;
} else if (argument.equals(new PackageIdentity("2"))) {
return parentAcl;
}
return null;
});
repo.update(pack);
verify(mutableAclService).updateAcl(acl);
verify(delegateRepository).update(pack);
}
use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class PackageRepositorySecurityDecoratorTest method testAdd.
@Test
public void testAdd() {
Package pack = mock(Package.class);
Package parent = mock(Package.class);
when(pack.getId()).thenReturn("1");
when(parent.getId()).thenReturn("2");
when(pack.getParent()).thenReturn(parent);
MutableAcl acl = mock(MutableAcl.class);
MutableAcl parentAcl = mock(MutableAcl.class);
when(mutableAclService.createAcl(new PackageIdentity("1"))).thenReturn(acl);
when(mutableAclService.readAclById(new PackageIdentity("2"))).thenReturn(parentAcl);
repo.add(pack);
verify(mutableAclService).createAcl(new PackageIdentity("1"));
verify(mutableAclService).updateAcl(acl);
verify(delegateRepository).add(pack);
}
Aggregations