use of com.yahoo.elide.core.security.permissions.expressions.SpecificFieldExpression in project elide by yahoo.
the class PermissionExpressionBuilder method buildSpecificFieldExpression.
/**
* Builder for specific field expressions.
*
* @param condition The condition which triggered this permission expression check
* @param checkFn Operation check function
* @param includeEntityPermission whether entity permission needs to be evaluated in the absence of field permission
* @return Expressions representing specific field
*/
private Expression buildSpecificFieldExpression(final PermissionCondition condition, final Function<Check, Expression> checkFn, boolean includeEntityPermission) {
Type<?> resourceClass = condition.getEntityClass();
Class<? extends Annotation> annotationClass = condition.getPermission();
String field = condition.getField().orElse(null);
ParseTree fieldPermissions = entityDictionary.getPermissionsForField(resourceClass, field, annotationClass);
if (includeEntityPermission) {
ParseTree classPermissions = entityDictionary.getPermissionsForClass(resourceClass, annotationClass);
return new SpecificFieldExpression(condition, normalizedExpressionFromParseTree(classPermissions, checkFn), normalizedExpressionFromParseTree(fieldPermissions, checkFn));
}
return new SpecificFieldExpression(condition, null, normalizedExpressionFromParseTree(fieldPermissions, checkFn));
}
Aggregations