Search in sources :

Example 11 with EntityTypeIdentity

use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.

the class EntityTypeRepositorySecurityDecoratorTest method findOneByIdFetchUserPermissionDenied.

@WithMockUser(username = USERNAME)
@Test
public void findOneByIdFetchUserPermissionDenied() {
    String entityType0Name = "entity0";
    Fetch fetch = mock(Fetch.class);
    when(permissionService.hasPermission(new EntityTypeIdentity(entityType0Name), EntityTypePermission.COUNT)).thenReturn(false);
    assertNull(repo.findOneById(entityType0Name, fetch));
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.testng.annotations.Test)

Example 12 with EntityTypeIdentity

use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.

the class EntityTypeRepositorySecurityDecorator method deleteAcl.

@Override
public void deleteAcl(Object entityTypeId) {
    mutableAclService.deleteAcl(new EntityTypeIdentity((String) entityTypeId), true);
    mutableAclClassService.deleteAclClass(EntityIdentityUtils.toType((String) entityTypeId));
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity)

Example 13 with EntityTypeIdentity

use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.

the class EntityTypeRepositorySecurityDecorator method createAcl.

@Override
public void createAcl(EntityType entityType) {
    MutableAcl acl = mutableAclService.createAcl(new EntityTypeIdentity(entityType.getId()));
    Package pack = entityType.getPackage();
    if (pack != null) {
        ObjectIdentity objectIdentity = new PackageIdentity(pack);
        acl.setParent(mutableAclService.readAclById(objectIdentity));
        mutableAclService.updateAcl(acl);
    }
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) PackageIdentity(org.molgenis.data.security.PackageIdentity) MutableAcl(org.springframework.security.acls.model.MutableAcl) Package(org.molgenis.data.meta.model.Package)

Example 14 with EntityTypeIdentity

use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.

the class EntityTypeRepositorySecurityDecorator method isOperationPermitted.

@Override
public boolean isOperationPermitted(Object id, Action action) {
    AbstractPermission permission = getPermissionForOperation(action);
    boolean hasPermission = userPermissionEvaluator.hasPermission(new EntityTypeIdentity(id.toString()), permission);
    if (hasPermission && !permission.equals(EntityTypePermission.COUNT)) {
        boolean isSystem = systemEntityTypeRegistry.hasSystemEntityType(id.toString());
        if (isSystem && !currentUserIsSystem()) {
            throw new MolgenisDataException(format("No [%s] permission on EntityType [%s]", toMessagePermission(action), id));
        }
    }
    return hasPermission;
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity) MolgenisDataException(org.molgenis.data.MolgenisDataException) AbstractPermission(org.springframework.security.acls.domain.AbstractPermission)

Example 15 with EntityTypeIdentity

use of org.molgenis.data.security.EntityTypeIdentity in project molgenis by molgenis.

the class EntityTypeRepositorySecurityDecorator method deleteAcl.

@Override
public void deleteAcl(EntityType entityType) {
    mutableAclService.deleteAcl(new EntityTypeIdentity(entityType), true);
    mutableAclClassService.deleteAclClass(EntityIdentityUtils.toType(entityType));
}
Also used : EntityTypeIdentity(org.molgenis.data.security.EntityTypeIdentity)

Aggregations

EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)75 Test (org.testng.annotations.Test)57 EntityType (org.molgenis.data.meta.model.EntityType)40 WithMockUser (org.springframework.security.test.context.support.WithMockUser)39 Attribute (org.molgenis.data.meta.model.Attribute)16 AggregateQuery (org.molgenis.data.aggregation.AggregateQuery)8 MutableAcl (org.springframework.security.acls.model.MutableAcl)8 EntityTypePermission (org.molgenis.data.security.EntityTypePermission)6 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)6 PrincipalSid (org.springframework.security.acls.domain.PrincipalSid)6 Sid (org.springframework.security.acls.model.Sid)6 Entity (org.molgenis.data.Entity)5 Package (org.molgenis.data.meta.model.Package)5 EntityTypePermissionUtils.getCumulativePermission (org.molgenis.data.security.EntityTypePermissionUtils.getCumulativePermission)4 QueryImpl (org.molgenis.data.support.QueryImpl)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 File (java.io.File)3 Map (java.util.Map)3 ADD (org.molgenis.data.DatabaseAction.ADD)3 FileRepositoryCollection (org.molgenis.data.file.support.FileRepositoryCollection)3