use of com.yahoo.elide.core.security.permissions.expressions.CheckExpression in project elide by yahoo.
the class PermissionToFilterExpressionVisitorTest method filterExpressionForPermissions.
private FilterExpression filterExpressionForPermissions(String permission) {
Function<Check, Expression> checkFn = (check) -> new CheckExpression(check, null, requestScope, null, cache);
ParseTree expression = EntityPermissions.parseExpression(permission);
PermissionToFilterExpressionVisitor fev = new PermissionToFilterExpressionVisitor(dictionary, requestScope, null);
return expression.accept(new PermissionExpressionVisitor(dictionary, checkFn)).accept(NORMALIZATION_VISITOR).accept(fev);
}
use of com.yahoo.elide.core.security.permissions.expressions.CheckExpression 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);
}
use of com.yahoo.elide.core.security.permissions.expressions.CheckExpression in project elide by yahoo.
the class PermissionExpressionNormalizationVisitorTest method setUp.
@BeforeAll
public void setUp() {
EntityDictionary dictionary = TestDictionary.getTestDictionary();
ElideSettings elideSettings = new ElideSettingsBuilder(null).withEntityDictionary(dictionary).build();
RequestScope requestScope = new RequestScope(null, null, NO_VERSION, null, null, null, null, null, UUID.randomUUID(), elideSettings);
permissionExpressionVisitor = new PermissionExpressionVisitor(dictionary, (check -> new CheckExpression(check, null, requestScope, null, null)));
normalizationVisitor = new PermissionExpressionNormalizationVisitor();
}
Aggregations