All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.att.research.xacmlatt.pdp.policy.expressions.ForAll Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 * Copyright (c) 2021, salesforce.com, inc.
 * All rights reserved.
 * SPDX-License-Identifier: MIT
 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
 */
package com.att.research.xacmlatt.pdp.policy.expressions;

import com.att.research.xacml.api.AttributeValue;
import com.att.research.xacmlatt.pdp.eval.EvaluationContext;
import com.att.research.xacmlatt.pdp.eval.EvaluationException;
import com.att.research.xacmlatt.pdp.policy.*;

/**
 * ForAll extends {@link QuantifiedExpression} to implement the behavior specified in section 5.2 of the
 * 
 * XACML v3.0 Related and Nested Entities Profile Version 1.0 specification.
 *
 * @author ygrignon
 */
public class ForAll extends QuantifiedExpression {
    /**
     * Constructs a ForAll quantified expression for this {@link LexicalEnvironment}.
     * @param lexicalEnvironment The parent lexical environment.
     */
    public ForAll(LexicalEnvironment lexicalEnvironment) {
        super(lexicalEnvironment);
    }

    @Override
    protected ExpressionResult processDomainResult(Bag domain, Bag resultBag, EvaluationContext evaluationContext, PolicyDefaults policyDefaults) throws EvaluationException {
        // ForAll evaluates to true if the domain is empty
        if (domain != null && domain.isEmpty()) {
            return ExpressionResultBoolean.ERB_TRUE;
        }

        // ForAll evaluates to true if evaluation made it all the way to the end
        ExpressionResult result = super.processDomainResult(domain, null, evaluationContext, policyDefaults);
        return result == ER_CONTINUE_PROCESSING ? ExpressionResultBoolean.ERB_TRUE : result;
    }

    @Override
    protected ExpressionResult processIterantResult(AttributeValue domainAttributeValue, ExpressionResult iterantResult, Bag resultBag) {
        // Convert the iterant result to a boolean result
        ExpressionResultBoolean expressionResultBoolean = ExpressionResultBoolean.fromExpressionResult(iterantResult);

        // Return the iterant result if it's not true, continue otherwise
        return expressionResultBoolean.isOk() && expressionResultBoolean.isTrue() ? ER_CONTINUE_PROCESSING : expressionResultBoolean;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy