Search in sources :

Example 1 with RangerAbstractConditionEvaluator

use of org.apache.ranger.plugin.conditionevaluator.RangerAbstractConditionEvaluator in project ranger by apache.

the class RangerDefaultPolicyItemEvaluator method matchCustomConditions.

@Override
public boolean matchCustomConditions(RangerAccessRequest request) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> RangerDefaultPolicyItemEvaluator.matchCustomConditions(" + request + ")");
    }
    boolean ret = true;
    if (CollectionUtils.isNotEmpty(conditionEvaluators)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("RangerDefaultPolicyItemEvaluator.matchCustomConditions(): conditionCount=" + conditionEvaluators.size());
        }
        for (RangerConditionEvaluator conditionEvaluator : conditionEvaluators) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("evaluating condition: " + conditionEvaluator);
            }
            RangerPerfTracer perf = null;
            if (RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYCONDITION_REQUEST_LOG)) {
                String conditionType = null;
                if (conditionEvaluator instanceof RangerAbstractConditionEvaluator) {
                    conditionType = ((RangerAbstractConditionEvaluator) conditionEvaluator).getPolicyItemCondition().getType();
                }
                perf = RangerPerfTracer.getPerfTracer(PERF_POLICYCONDITION_REQUEST_LOG, "RangerConditionEvaluator.matchCondition(policyId=" + policyId + ",policyItemIndex=" + getPolicyItemIndex() + ",policyConditionType=" + conditionType + ")");
            }
            boolean conditionEvalResult = conditionEvaluator.isMatched(request);
            RangerPerfTracer.log(perf);
            if (!conditionEvalResult) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(conditionEvaluator + " returned false");
                }
                ret = false;
                break;
            }
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("<== RangerDefaultPolicyItemEvaluator.matchCustomConditions(" + request + "): " + ret);
    }
    return ret;
}
Also used : RangerAbstractConditionEvaluator(org.apache.ranger.plugin.conditionevaluator.RangerAbstractConditionEvaluator) RangerConditionEvaluator(org.apache.ranger.plugin.conditionevaluator.RangerConditionEvaluator) RangerPerfTracer(org.apache.ranger.plugin.util.RangerPerfTracer)

Aggregations

RangerAbstractConditionEvaluator (org.apache.ranger.plugin.conditionevaluator.RangerAbstractConditionEvaluator)1 RangerConditionEvaluator (org.apache.ranger.plugin.conditionevaluator.RangerConditionEvaluator)1 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)1