Search in sources :

Example 51 with Identifiable

use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.

the class AbstractTransitiveEvaluator method getPermissions.

/**
 * Returns transitive permissions by entity's owner
 * @param entity
 * @param policy
 * @return
 */
@Override
public Set<String> getPermissions(E entity, AuthorizationPolicy policy) {
    Set<String> permissions = super.getPermissions(entity, policy);
    if (entity == null || !securityService.isAuthenticated()) {
        return permissions;
    }
    // evaluates permissions on owner class
    Identifiable owner = getOwner(entity);
    // If is owner null, then now permissions well be granted.
    if (owner == null) {
        return Sets.newHashSet();
    }
    Set<String> transitivePermissions = authorizationManager.getPermissions(owner);
    // configured permissions - reduce permissions (intersection)
    Set<String> includePermissions = getIncludePermissions(policy);
    if (includePermissions.isEmpty()) {
        return transitivePermissions;
    }
    // 
    Set<String> result = transitivePermissions.stream().filter(includePermissions::contains).collect(Collectors.toSet());
    return result;
}
Also used : Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable)

Aggregations

Identifiable (eu.bcvsolutions.idm.core.api.domain.Identifiable)51 Test (org.junit.Test)37 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)32 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)31 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)27 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)24 DefaultAttachmentManagerIntegrationTest (eu.bcvsolutions.idm.core.ecm.service.impl.DefaultAttachmentManagerIntegrationTest)24 List (java.util.List)19 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)16 UUID (java.util.UUID)16 ArrayList (java.util.ArrayList)14 IdmAttachmentDto (eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto)12 Autowired (org.springframework.beans.factory.annotation.Autowired)11 Transactional (org.springframework.transaction.annotation.Transactional)11 Lists (com.google.common.collect.Lists)10 Serializable (java.io.Serializable)10 HashSet (java.util.HashSet)10 Map (java.util.Map)10 PersistentType (eu.bcvsolutions.idm.core.eav.api.domain.PersistentType)9