Class MutableAttributeBag<AV extends AttributeValue>

  • Type Parameters:
    AV - element type (primitive). Indeed, XACML spec says for Attribute Bags (7.3.2): "There SHALL be no notion of a bag containing bags, or a bag containing values of differing types; i.e., a bag in XACML SHALL contain only values that are of the same data-type."
    All Implemented Interfaces:
    Iterable<AV>

    public final class MutableAttributeBag<AV extends AttributeValue>
    extends Object
    implements Iterable<AV>
    Growable/updatable attribute bag, i.e. mutable bag of attribute values to which you can add as many values as you can. Used only when the total number of values for a given attribute - typically in a XACML request - is not known in advance. For example, for the same AttributeId (e.g. with Issuer = null), there might be multiple elements, in which case values must be merged for later matching evaluation. Indeed, as discussed on the xacml-dev mailing list (see https://lists.oasis-open.org/archives/xacml-dev/201507/msg00001.html), the following excerpt from the XACML 3.0 core spec, ยง7.3.3, indicates that multiple occurrences of the same with same meta-data but different values should be considered equivalent to a single element with same meta-data and merged values (multi-valued Attribute). Moreover, the conformance test 'IIIA024' expects this behavior: the multiple subject-id Attributes are expected to result in a multi-value bag during evaluation of the AttributeDesignator.

    To be instantiated only in a given evaluation request context (handled by a single thread), otherwise not guaranteed thread-safe.

    • Constructor Detail

      • MutableAttributeBag

        public MutableAttributeBag​(Datatype<AV> elementDatatype,
                                   AttributeSource attributeSource)
                            throws IllegalArgumentException
        Parameters:
        elementDatatype - primitive datatype factory to create every element/value in the bag
        attributeSource - attribute bag source
        Throws:
        IllegalArgumentException - iff elementDatatypeFactory == null || attributeSource == null
    • Method Detail

      • getElementType

        public Datatype<AV> getElementType()
        Returns bag element datatype
        Returns:
        the elementType
      • add

        public void add​(AV value)
        Adds value to bag
        Parameters:
        value - attribute value
        Throws:
        IllegalArgumentException - if value == null
      • toImmutable

        public AttributeBag<AV> toImmutable()
        Lock the bag and return the immutable copy of this bag
        Returns:
        immutable bag
      • addAll

        public void addAll​(Collection<? extends AttributeValue> list)
                    throws IllegalArgumentException,
                           ClassCastException
        Appends all of the elements in the specified collection to the end of this bag, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
        Parameters:
        list - collection containing elements to be added to this list
        Throws:
        IllegalArgumentException - if list is null
        ClassCastException - if one of the values in list is not assignable to the type AV