Class AttributeFilter


  • public final class AttributeFilter
    extends Object
    A configurable factory for filtering the attributes exposed by an entry. An AttributeFilter is useful for performing fine-grained access control, selecting attributes based on search request criteria, and selecting attributes based on post- and pre- read request control criteria.

    In cases where methods accept a string based list of attribute descriptions, the following special attribute descriptions are permitted:

    • * - include all user attributes
    • + - include all operational attributes
    • 1.1 - exclude all attributes
    • @objectclass - include all attributes identified by the named object class.
    • Constructor Detail

      • AttributeFilter

        public AttributeFilter()
        Creates a new attribute filter which will include all user attributes but no operational attributes.
      • AttributeFilter

        public AttributeFilter​(Collection<String> attributeDescriptions)
        Creates a new attribute filter which will include the attributes identified by the provided search request attribute list. Attributes will be decoded using the default schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescriptions - The names of the attributes to be included with each entry.
      • AttributeFilter

        public AttributeFilter​(Collection<String> attributeDescriptions,
                               Schema schema)
        Creates a new attribute filter which will include the attributes identified by the provided search request attribute list. Attributes will be decoded using the provided schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescriptions - The names of the attributes to be included with each entry.
        schema - The schema The schema to use when parsing attribute descriptions and object class names.
      • AttributeFilter

        public AttributeFilter​(String... attributeDescriptions)
        Creates a new attribute filter which will include the attributes identified by the provided search request attribute list. Attributes will be decoded using the default schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescriptions - The names of the attributes to be included with each entry.
    • Method Detail

      • allUserAndOperationalAttributesFilter

        public static AttributeFilter allUserAndOperationalAttributesFilter()
        Creates a new attribute filter which will include all user and operational attributes.
        Returns:
        A new attribute filter which includes all user and operational attributes.
      • filteredCopyOf

        public Entry filteredCopyOf​(Entry entry)
        Returns a modifiable filtered copy of the provided entry.
        Parameters:
        entry - The entry to be filtered and copied.
        Returns:
        The modifiable filtered copy of the provided entry.
      • filteredViewOf

        public Entry filteredViewOf​(Entry entry)
        Returns an unmodifiable filtered view of the provided entry. The returned entry supports all operations except those which modify the contents of the entry.
        Parameters:
        entry - The entry to be filtered.
        Returns:
        The unmodifiable filtered view of the provided entry.
      • includeAllOperationalAttributes

        public AttributeFilter includeAllOperationalAttributes​(boolean include)
        Specifies whether all operational attributes should be included in filtered entries. By default operational attributes are not included.
        Parameters:
        include - true if operational attributes should be included in filtered entries.
        Returns:
        A reference to this attribute filter.
      • includeAllUserAttributes

        public AttributeFilter includeAllUserAttributes​(boolean include)
        Specifies whether all user attributes should be included in filtered entries. By default user attributes are included.
        Parameters:
        include - true if user attributes should be included in filtered entries.
        Returns:
        A reference to this attribute filter.
      • includeAttribute

        public AttributeFilter includeAttribute​(AttributeDescription attributeDescription)
        Specifies that the named attribute should be included in filtered entries.
        Parameters:
        attributeDescription - The name of the attribute to be included in filtered entries.
        Returns:
        A reference to this attribute filter.
      • includeAttribute

        public AttributeFilter includeAttribute​(String attributeDescription)
        Specifies that the named attribute should be included in filtered entries. The attribute will be decoded using the default schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescription - The name of the attribute to be included in filtered entries.
        Returns:
        A reference to this attribute filter.
      • includeAttribute

        public AttributeFilter includeAttribute​(String attributeDescription,
                                                Schema schema)
        Specifies that the named attribute should be included in filtered entries. The attribute will be decoded using the provided schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescription - The name of the attribute to be included in filtered entries.
        schema - The schema The schema to use when parsing attribute descriptions and object class names.
        Returns:
        A reference to this attribute filter.
      • includeAttribute

        public AttributeFilter includeAttribute​(String attributeDescription,
                                                Schema schema,
                                                boolean includeAttributesFromSuperiors)
        Specifies that the named attribute should be included in filtered entries. The attribute will be decoded using the provided schema. See the class description for details regarding the types of supported attribute description.
        Parameters:
        attributeDescription - The name of the attribute to be included in filtered entries.
        schema - The schema The schema to use when parsing attribute descriptions and object class names.
        includeAttributesFromSuperiors - true if attribute expansion from object classes using the '@OC' syntax should also include attributes from superior classes in the list of requested attributes; false otherwise.
        Returns:
        A reference to this attribute filter.
      • mapAttributes

        public AttributeFilter mapAttributes​(Function<Attribute,​Attribute> mapper)
        Registers a mapping function which should be applied to attributes selected by this attribute filter. Mapping functions and filter predicates will be applied in registration order and may return null indicating that the attribute should not be included in the filtered entry (at which point no further mappings will be applied). Mapping functions must not mutate the passed in attributes and should instead return a new attribute representing the transformed attribute.
        Parameters:
        mapper - The mapping function responsible for transforming selected attributes. The function may return null if the attribute should not be included in the filtered entry.
        Returns:
        A reference to this attribute filter.
        See Also:
        filterAttributes(Predicate)
      • filterAttributes

        public AttributeFilter filterAttributes​(Predicate<Attribute> filter)
        Registers a predicate which should be applied to attributes selected by this attribute filter. Predicates must return true if the attribute should be included in the filtered entry. Mapping functions and filter predicates will be applied in registration order.
        Parameters:
        filter - The predicate which should be applied to attributes selected by this attribute filter. Predicates must return true if the attribute should be included in the filtered entry.
        Returns:
        A reference to this attribute filter.
        See Also:
        mapAttributes(Function)
      • matchesAllAttributes

        public boolean matchesAllAttributes()
        Returns true if this attribute filter matches all attributes, regardless of whether they are user or operational attributes.
        Returns:
        true if this attribute filter matches all attributes.
      • matchesAllUserAttributes

        public boolean matchesAllUserAttributes()
        Returns true if this attribute filter matches all user attributes.
        Returns:
        true if this attribute filter matches all user attributes.
      • matchesAllOperationalAttributes

        public boolean matchesAllOperationalAttributes()
        Returns true if this attribute filter matches all operational attributes.
        Returns:
        true if this attribute filter matches all operational attributes.
      • matchesAnyAttributes

        public boolean matchesAnyAttributes()
        Returns true if this attribute filter may match some attributes, or false if it will never match any attributes.
        Returns:
        true if this attribute filter may match some attributes.
      • matchesAttribute

        public boolean matchesAttribute​(AttributeDescription attributeDescription)
        Returns true if this attribute filter matches the provided attribute description.
        Parameters:
        attributeDescription - The attribute description.
        Returns:
        true if this attribute filter matches the provided attribute description.
      • typesOnly

        public AttributeFilter typesOnly​(boolean typesOnly)
        Specifies whether filtered attributes are to contain both attribute descriptions and values, or just attribute descriptions.
        Parameters:
        typesOnly - true if only attribute descriptions (and not values) are to be included, or false (the default) if both attribute descriptions and values are to be included.
        Returns:
        A reference to this attribute filter.