Search in sources :

Example 1 with SpecificFieldExpression

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));
}
Also used : SpecificFieldExpression(com.yahoo.elide.core.security.permissions.expressions.SpecificFieldExpression) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

SpecificFieldExpression (com.yahoo.elide.core.security.permissions.expressions.SpecificFieldExpression)1 ParseTree (org.antlr.v4.runtime.tree.ParseTree)1