Interface AttributeValueFactory<AV extends AttributeValue>

  • Type Parameters:
    AV - type of instance (attribute value) created by this factory
    All Superinterfaces:
    PdpExtension
    All Known Implementing Classes:
    BaseAttributeValueFactory, SimpleValue.BaseFactory, StringContentOnlyValueFactory, StringParseableValue.Factory

    public interface AttributeValueFactory<AV extends AttributeValue>
    extends PdpExtension
    Datatype-specific Attribute Value Factory/Parser.

    Note: In XACML, AttributeValues may be parsed from various sources: XACML Policy(Set), XACML Request, etc. Besides, there may be more than one possible factory/parser for a given datatype, e.g. if there are different input data formats. For example, an XACML integer is represented as an XML text in XACML/XML core specification, and therefore results in a Java String with JAXB framework; whereas in JSON Profile, it would be a JSON number and would result in Java Number with most JSON frameworks.

    • Method Detail

      • getDatatype

        AttributeDatatype<AV> getDatatype()
        Get datatype of values created by this factory
        Returns:
        supported attribute value datatype
      • getInstance

        AV getInstance​(List<Serializable> content,
                       Map<QName,​String> otherAttributes,
                       net.sf.saxon.s9api.XPathCompiler xPathCompiler)
                throws IllegalArgumentException
        Create AttributeValue in internal model (suitable for Expression evaluators) from XML/JAXB mixed content and other XML attributes.

        NB: the standard datatype 'xpathExpression' may seem like a special case because xpathExpression evaluation depends on the context; therefore it might seem like a good idea to have 'xpathExpression' datatype factory - and this interface as a result - use Expression as return type of this method instead. However, we prefer to avoid that for simplicity. Indeed, if we need to evaluate a 'xpathExpression', we don't need a generic interface like Expression because in standard XACML, xpathExpressions are used only as parameters of XPath-based functions (A.3.15), and such functions just need to cast input values to XPathValue and call XPathValue.evaluate(org.ow2.authzforce.core.pdp.api.EvaluationContext) for evaluation. Outside the context of XPath-based functions, we may consider xpathExpressions as simple literal constants like other AttributeValues.

        Parameters:
        content - raw value's mixed content, e.g. an element might be a String for text, or Element for XML element in the case of core XACML (XML) implemented with JAXB framework; or possibly Number or Boolean in the case of JSON Profile of XACML implemented with common JSON frameworks. This list is a singleton in most cases.
        otherAttributes - non-null/mandatory list of other XML attributes of the value node; may be empty if none
        xPathCompiler - XPath compiler for compiling/evaluating XPath expressions in values, e.g. XACML xpathExpression
        Returns:
        attribute value in internal model suitable for Expression evaluators
        Throws:
        IllegalArgumentException - if content/otherAttributes are not valid for the datatype handled by this factory