use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecoratorTest method testAddStream.
@WithMockUser(username = USERNAME)
@Test
public void testAddStream() {
Entity entity = getEntityMock();
MutableAcl acl = mock(MutableAcl.class);
when(mutableAclService.createAcl(new EntityIdentity(entity))).thenReturn(acl);
rowLevelSecurityRepositoryDecorator.add(Stream.of(entity));
@SuppressWarnings("unchecked") ArgumentCaptor<Stream<Entity>> entityStreamCaptor = ArgumentCaptor.forClass(Stream.class);
verify(delegateRepository).add(entityStreamCaptor.capture());
assertEquals(entityStreamCaptor.getValue().collect(toList()), singletonList(entity));
verify(acl).insertAce(0, new CumulativePermission().set(WRITE).set(READ).set(COUNT), new PrincipalSid(USERNAME), true);
}
use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class PermissionSystemServiceImplTest method giveUserEntityPermissions.
@Test
@WithMockUser(username = "user")
public void giveUserEntityPermissions() {
String entityTypeId = "entityTypeId";
EntityType entityType = when(mock(EntityType.class).getId()).thenReturn(entityTypeId).getMock();
MutableAcl acl = mock(MutableAcl.class);
when(mutableAclService.readAclById(new EntityTypeIdentity(entityTypeId))).thenReturn(acl);
permissionSystemServiceImpl.giveUserWriteMetaPermissions(entityType);
verify(mutableAclService).updateAcl(acl);
verify(acl).insertAce(0, new CumulativePermission().set(EntityTypePermission.WRITEMETA).set(EntityTypePermission.WRITE).set(EntityTypePermission.READ).set(EntityTypePermission.COUNT), new PrincipalSid("user"), true);
}
use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class PermissionSystemServiceImpl method giveUserWriteMetaPermissions.
@Override
public void giveUserWriteMetaPermissions(Collection<EntityType> entityTypes) {
Sid sid = SidUtils.createSid(getCurrentUsername());
runAsSystem(() -> {
CumulativePermission permission = getCumulativePermission(EntityTypePermission.WRITEMETA);
entityTypes.forEach(entityType -> {
MutableAcl acl = (MutableAcl) mutableAclService.readAclById(new EntityTypeIdentity(entityType));
acl.insertAce(acl.getEntries().size(), permission, sid, true);
mutableAclService.updateAcl(acl);
});
});
}
use of org.springframework.security.acls.model.MutableAcl in project molgenis by molgenis.
the class RowLevelSecurityRepositoryDecorator method createAcl.
@Override
public void createAcl(Entity entity) {
MutableAcl acl = mutableAclService.createAcl(new EntityIdentity(entity));
Sid sid = new PrincipalSid(SecurityUtils.getCurrentUsername());
acl.insertAce(acl.getEntries().size(), EntityPermissionUtils.getCumulativePermission(WRITE), sid, true);
mutableAclService.updateAcl(acl);
}
use of org.springframework.security.acls.model.MutableAcl in project spring-security by spring-projects.
the class SpringCacheBasedAclCache method evictFromCache.
@Override
public void evictFromCache(ObjectIdentity objectIdentity) {
Assert.notNull(objectIdentity, "ObjectIdentity required");
MutableAcl acl = getFromCache(objectIdentity);
if (acl != null) {
this.cache.evict(acl.getId());
this.cache.evict(acl.getObjectIdentity());
}
}
Aggregations