use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class AggregationDataStore method validateModelExpressionChecks.
/**
* Validates The security Check expression type for both Table and all its fields.
* Table Security Check Condition - User Checks and Filter Expression Checks
* Field Security Check Condition - User Checks
* @param dictionary - Entity Dictionary
* @param clz - Model Type.
*/
private void validateModelExpressionChecks(EntityDictionary dictionary, Type<?> clz) {
PermissionExpressionVisitor visitor = new PermissionExpressionVisitor();
ParseTree parseTree = dictionary.getPermissionsForClass(clz, ReadPermission.class);
if (parseTree != null) {
validateExpression(dictionary, visitor.visit(parseTree), (checkClass) -> UserCheck.class.isAssignableFrom(checkClass) || FilterExpressionCheck.class.isAssignableFrom(checkClass), "Table Can only have User Check and Filter Expression Check." + "Operation Checks Not allowed. given - %s");
}
dictionary.getAllExposedFields(clz).stream().map(field -> dictionary.getPermissionsForField(clz, field, ReadPermission.class)).filter(Objects::nonNull).forEach(tree -> validateExpression(dictionary, visitor.visit(tree), (checkClass) -> UserCheck.class.isAssignableFrom(checkClass), "Fields Can only have User checks. Given - %s"));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class AggregationDataStoreTransaction method throwReadOnlyException.
private <T> void throwReadOnlyException(T entity) {
EntityDictionary dictionary = metaDataStore.getMetadataDictionary();
Type<?> type = dictionary.getType(entity);
throw new InvalidOperationException(dictionary.getJsonAliasFor(type) + " is read only.");
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testComplexTrueExpression.
@Test
public void testComplexTrueExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "(Filter Expression Check AND False User Check) OR (Filter Expression Check OR NOT False User Check)")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testFalseUserAndOperationExpression.
@Test
public void testFalseUserAndOperationExpression() throws Exception {
@Entity
@Include(rootLevel = false)
class Book {
@Id
private long id;
@ReadPermission(expression = "False User Check AND In Memory Check")
private String title;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
use of com.yahoo.elide.core.dictionary.EntityDictionary in project elide by yahoo.
the class CanPaginateVisitorTest method testMultipleFieldsPagination.
@Test
public void testMultipleFieldsPagination() throws Exception {
@Entity
@Include(rootLevel = false)
@ReadPermission(expression = "In Memory Check")
class Book {
@Id
private long id;
@ReadPermission(expression = "Filter Expression Check")
private String title;
@ReadPermission(expression = "Filter Expression Check")
private Date publicationDate;
}
EntityDictionary dictionary = TestDictionary.getTestDictionary(checkMappings);
dictionary.bindEntity(Book.class);
RequestScope scope = mock(RequestScope.class);
assertTrue(CanPaginateVisitor.canPaginate(ClassType.of(Book.class), dictionary, scope, new HashSet<>()));
}
Aggregations