Search in sources :

Example 1 with UserCheck

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();
}
Also used : UserCheck(com.yahoo.elide.core.security.checks.UserCheck) Map(java.util.Map) BiMap(com.google.common.collect.BiMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashBiMap(com.google.common.collect.HashBiMap)

Example 2 with UserCheck

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);
}
Also used : UserCheck(com.yahoo.elide.core.security.checks.UserCheck)

Example 3 with UserCheck

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;
}
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

UserCheck (com.yahoo.elide.core.security.checks.UserCheck)3 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 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 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1