use of com.yahoo.elide.core.security.permissions.expressions.AndExpression in project elide by yahoo.
the class PermissionExpressionNormalizationVisitor method visitNotExpression.
@Override
public Expression visitNotExpression(NotExpression notExpression) {
Expression inner = notExpression.getLogical();
if (inner instanceof AndExpression) {
AndExpression and = (AndExpression) inner;
Expression left = new NotExpression(and.getLeft()).accept(this);
Expression right = new NotExpression(and.getRight()).accept(this);
return new OrExpression(left, right);
}
if (inner instanceof OrExpression) {
OrExpression or = (OrExpression) inner;
Expression left = new NotExpression(or.getLeft()).accept(this);
Expression right = new NotExpression(or.getRight()).accept(this);
return new AndExpression(left, right);
}
if (inner instanceof NotExpression) {
NotExpression not = (NotExpression) inner;
return (not.getLogical()).accept(this);
}
return notExpression;
}
use of com.yahoo.elide.core.security.permissions.expressions.AndExpression in project elide by yahoo.
the class PermissionExpressionNormalizationVisitor method visitAndExpression.
@Override
public Expression visitAndExpression(AndExpression andExpression) {
Expression left = andExpression.getLeft();
Expression right = andExpression.getRight();
return new AndExpression(left.accept(this), right.accept(this));
}
use of com.yahoo.elide.core.security.permissions.expressions.AndExpression in project elide by yahoo.
the class PermissionExpressionVisitor method visitAND.
@Override
public Expression visitAND(ExpressionParser.ANDContext ctx) {
Expression left = visit(ctx.left);
Expression right = visit(ctx.right);
return new AndExpression(left, right);
}
use of com.yahoo.elide.core.security.permissions.expressions.AndExpression in project elide by yahoo.
the class PermissionExpressionBuilder method buildUserCheckEntityAndAnyFieldExpression.
/**
* Build an expression that strictly evaluates UserCheck's and ignores other checks for an entity.
* expression = (entityRule AND (field1Rule OR field2Rule ... OR fieldNRule))
* <p>
* NOTE: This method returns _NO_ commit checks.
*
* @param resourceClass Resource class
* @param annotationClass Annotation class
* @param scope Request scope
* @param <A> type parameter
* @return User check expression to evaluate
*/
public <A extends Annotation> Expression buildUserCheckEntityAndAnyFieldExpression(final Type<?> resourceClass, final Class<A> annotationClass, Set<String> requestedFields, final RequestScope scope) {
final Function<Check, Expression> leafBuilderFn = (check) -> new CheckExpression(check, null, scope, null, cache);
ParseTree classPermissions = entityDictionary.getPermissionsForClass(resourceClass, annotationClass);
Expression entityExpression = normalizedExpressionFromParseTree(classPermissions, leafBuilderFn);
Expression anyFieldExpression = buildAnyFieldOnlyExpression(new PermissionCondition(annotationClass, resourceClass), leafBuilderFn, requestedFields);
if (entityExpression == null) {
return anyFieldExpression;
}
return new AndExpression(entityExpression, anyFieldExpression);
}
Aggregations