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;
}
Aggregations