Search in sources :

Example 1 with FilterExpressionCheck

use of com.yahoo.elide.core.security.checks.FilterExpressionCheck in project elide by yahoo.

the class PermissionToFilterExpressionVisitor method visitCheckExpression.

@Override
public FilterExpression visitCheckExpression(CheckExpression checkExpression) {
    Check check = checkExpression.getCheck();
    if (check instanceof FilterExpressionCheck) {
        FilterExpressionCheck filterCheck = (FilterExpressionCheck) check;
        FilterExpression filterExpression = filterCheck.getFilterExpression(entityClass, requestScope);
        if (filterExpression == null) {
            throw new IllegalStateException("FilterCheck#getFilterExpression must not return null.");
        }
        return filterExpression;
    }
    if (check instanceof UserCheck) {
        boolean userCheckResult = ((UserCheck) check).ok(requestScope.getUser());
        return userCheckResult ? TRUE_USER_CHECK_EXPRESSION : FALSE_USER_CHECK_EXPRESSION;
    }
    return NO_EVALUATION_EXPRESSION;
}
Also used : UserCheck(com.yahoo.elide.core.security.checks.UserCheck) FilterExpressionCheck(com.yahoo.elide.core.security.checks.FilterExpressionCheck) Check(com.yahoo.elide.core.security.checks.Check) UserCheck(com.yahoo.elide.core.security.checks.UserCheck) FilterExpressionCheck(com.yahoo.elide.core.security.checks.FilterExpressionCheck) NotFilterExpression(com.yahoo.elide.core.filter.expression.NotFilterExpression) OrFilterExpression(com.yahoo.elide.core.filter.expression.OrFilterExpression) AndFilterExpression(com.yahoo.elide.core.filter.expression.AndFilterExpression) FilterExpression(com.yahoo.elide.core.filter.expression.FilterExpression)

Aggregations

AndFilterExpression (com.yahoo.elide.core.filter.expression.AndFilterExpression)1 FilterExpression (com.yahoo.elide.core.filter.expression.FilterExpression)1 NotFilterExpression (com.yahoo.elide.core.filter.expression.NotFilterExpression)1 OrFilterExpression (com.yahoo.elide.core.filter.expression.OrFilterExpression)1 Check (com.yahoo.elide.core.security.checks.Check)1 FilterExpressionCheck (com.yahoo.elide.core.security.checks.FilterExpressionCheck)1 UserCheck (com.yahoo.elide.core.security.checks.UserCheck)1