Interface ExpressionFactory


  • public interface ExpressionFactory
    Expression factory for parsing XACML ExpressionTypes in policies: AttributeDesignator, AttributeSelector, Apply, etc.
    • Method Detail

      • isXPathEnabled

        boolean isXPathEnabled()
        XPath support status
        Returns:
        true iff XPath support enabled, else it is disabled
      • getInstance

        Expression<?> getInstance​(oasis.names.tc.xacml._3_0.core.schema.wd_17.ExpressionType expr,
                                  Deque<String> longestVarRefChain,
                                  Optional<XPathCompilerProxy> xPathCompiler)
                           throws IllegalArgumentException
        Parses an XACML Expression into internal model of expression (evaluable).
        Parameters:
        expr - the JAXB ExpressionType derived from XACML model
        xPathCompiler - Policy(Set) default XPath compiler, corresponding to the Policy(Set)'s default XPath version specified in DefaultsType element. Undefined if no such XPath version defined or XPath support disabled (isXPathEnabled() returns false).
        longestVarRefChain - Longest chain of VariableReference references in the VariableDefinition's expression that is expr or contains expr, or null if expr is not in a VariableDefinition. A VariableReference reference chain is a list of VariableIds, such that V1-> V2 ->... -> Vn -> expr , where "V1 -> V2" means: the expression in VariableDefinition of V1 has a VariableReference to V2. This is used to detect exceeding depth of VariableReference reference in VariableDefinitions' expressions. Again, longestVarRefChain may be null, if this expression is not used in a VariableDefinition.
        Returns:
        an Expression or null if the root node cannot be parsed as a valid Expression
        Throws:
        IllegalArgumentException - invalid ExpressionType
      • getInstance

        ConstantExpression<? extends AttributeValue> getInstance​(oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType jaxbAttrVal,
                                                                 Optional<XPathCompilerProxy> xPathCompiler)
                                                          throws IllegalArgumentException
        Parse/create an attribute value expression from XACML-schema-derived JAXB model
        Parameters:
        jaxbAttrVal - XACML-schema-derived JAXB AttributeValue
        xPathCompiler - Policy(Set) default XPath compiler, corresponding to the Policy(Set)'s default XPath version specified in DefaultsType element. Undefined if no such XPath version defined or XPath support disabled (isXPathEnabled() returns false).
        Returns:
        attribute value Expression
        Throws:
        IllegalArgumentException - if value cannot be parsed into the value's defined datatype
      • addVariable

        VariableReference<?> addVariable​(oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinition varDef,
                                         Deque<String> longestVarRefChain,
                                         Optional<XPathCompilerProxy> xPathCompiler)
                                  throws IllegalArgumentException
        Add VariableDefinition (variable assignment expression)
        Parameters:
        varDef - VariableDefinition
        xPathCompiler - Policy(Set) default XPath compiler, corresponding to the Policy(Set)'s default XPath version specified in DefaultsType element. Undefined if no such XPath version defined or XPath support disabled (isXPathEnabled() returns false).
        longestVarRefChain - Ignored if null else used as inout parameter to be filled by this method with the longest chain of VariableReference references in varDef. A VariableReference reference chain is a list of VariableIds, such that V1-> V2 ->... -> Vn -> expr , where "V1 -> V2" means: the expression in VariableDefinition of V1 has a VariableReference to V2. This is used to detect exceeding depth of VariableReference reference in VariableDefinitions' expressions. Again, longestVarRefChain may be null, if this expression is not used in a VariableDefinition.
        Returns:
        The previous VariableReference if VariableId already used
        Throws:
        IllegalArgumentException - invalid expression in varDef
      • getVariableExpression

        VariableReference<?> getVariableExpression​(String varId)
        Get a given variable's assignment expression (definition)
        Parameters:
        varId - variable identifier
        Returns:
        the VariableReference identified by varId , or null if there is no such variable.
      • getVariableExpressions

        com.google.common.collect.ImmutableList<VariableReference<?>> getVariableExpressions()
        Get a snapshot list of current Variable definitions. Order matters as a variable X must be declared in the list after any variable that it depends on. One use for this is to be able to declare all possible variables that may occur in a AttributeSelector's XPath expression, therefore all need to be declared on the XPath compiler with XPathCompiler.declareVariable(QName, ItemType, OccurrenceIndicator).
        Returns:
        a new copy of the current list of Variable definitions, empty if there is no such declared variable.
      • removeVariable

        VariableReference<?> removeVariable​(String varId)
        Removes the VariableReference(Definition) from the manager
        Parameters:
        varId - variable identifier
        Returns:
        the VariableReference previously identified by varId , or null if there was no such variable.
      • getFunction

        FunctionExpression getFunction​(String functionId)
        Gets a non-generic function instance
        Parameters:
        functionId - function ID (XACML URI)
        Returns:
        function instance; or null if no such function with ID functionId
      • getFunction

        FunctionExpression getFunction​(String functionId,
                                       Datatype<? extends AttributeValue> subFunctionReturnType)
                                throws IllegalArgumentException
        Gets a function instance (generic or non-generic).
        Parameters:
        functionId - function ID (XACML URI)
        subFunctionReturnType - optional sub-function's return type required only if a generic higher-order function is expected as the result, of which the sub-function is expected to be the first parameter; otherwise null (for first-order function). A generic higher-order function is a function whose return type depends on the sub-function ('s return type). Note: we only support sub-functions with primitive return type here, for simplicity (see HigherOrderBagFunction for more info).
        Returns:
        function instance; or null if no such function with ID functionId, or if non-null subFunctionReturnTypeId specified and no higher-order function compatible with sub-function's return type subFunctionReturnTypeId
        Throws:
        IllegalArgumentException - if datatype subFunctionReturnType is not supported