use of com.yahoo.elide.core.security.checks.UserCheck in project elide by yahoo.
the class EntityDictionary method getCheckIdentifier.
/**
* Returns the friendly named mapped to this given check.
* @param checkClass The class to lookup
* @return the friendly name of the check.
*/
public String getCheckIdentifier(Class<? extends Check> checkClass) {
String identifier = checkNames.inverse().get(checkClass);
if (identifier != null) {
return identifier;
}
if (UserCheck.class.isAssignableFrom(checkClass)) {
for (Map.Entry<String, UserCheck> entry : roleChecks.entrySet()) {
UserCheck check = entry.getValue();
String name = entry.getKey();
if (check.getClass().equals(checkClass)) {
return name;
}
}
}
return checkClass.getName();
}
use of com.yahoo.elide.core.security.checks.UserCheck in project elide by yahoo.
the class EntityDictionary method initializeChecks.
private void initializeChecks() {
UserCheck all = new Role.ALL();
UserCheck none = new Role.NONE();
addRoleCheck("Prefab.Role.All", all);
addRoleCheck(ALL_ROLE, all);
addRoleCheck("Prefab.Role.None", none);
addRoleCheck(NONE_ROLE, none);
addPrefabCheck("Prefab.Collections.AppendOnly", AppendOnly.class);
addPrefabCheck("Prefab.Collections.RemoveOnly", RemoveOnly.class);
}
use of com.yahoo.elide.core.security.checks.UserCheck 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;
}
Aggregations