Package org.forgerock.opendj.ldap
Class AttributeFilter
- java.lang.Object
-
- org.forgerock.opendj.ldap.AttributeFilter
-
public final class AttributeFilter extends Object
A configurable factory for filtering the attributes exposed by an entry. AnAttributeFilteris 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 Summary
Constructors Constructor Description AttributeFilter()Creates a new attribute filter which will include all user attributes but no operational attributes.AttributeFilter(String... attributeDescriptions)Creates a new attribute filter which will include the attributes identified by the provided search request attribute list.AttributeFilter(Collection<String> attributeDescriptions)Creates a new attribute filter which will include the attributes identified by the provided search request attribute list.AttributeFilter(Collection<String> attributeDescriptions, Schema schema)Creates a new attribute filter which will include the attributes identified by the provided search request attribute list.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AttributeFilterallUserAndOperationalAttributesFilter()Creates a new attribute filter which will include all user and operational attributes.AttributeFilterfilterAttributes(Predicate<Attribute> filter)Registers a predicate which should be applied to attributes selected by this attribute filter.EntryfilteredCopyOf(Entry entry)Returns a modifiable filtered copy of the provided entry.SearchResultEntryfilteredCopyOf(SearchResultEntry entry)Returns a modifiable filtered copy of the provided search result entry.EntryfilteredViewOf(Entry entry)Returns an unmodifiable filtered view of the provided entry.SearchResultEntryfilteredViewOf(SearchResultEntry entry)Returns an unmodifiable filtered view of the provided search result entry.AttributeFilterincludeAllOperationalAttributes(boolean include)Specifies whether all operational attributes should be included in filtered entries.AttributeFilterincludeAllUserAttributes(boolean include)Specifies whether all user attributes should be included in filtered entries.AttributeFilterincludeAttribute(String attributeDescription)Specifies that the named attribute should be included in filtered entries.AttributeFilterincludeAttribute(String attributeDescription, Schema schema)Specifies that the named attribute should be included in filtered entries.AttributeFilterincludeAttribute(String attributeDescription, Schema schema, boolean includeAttributesFromSuperiors)Specifies that the named attribute should be included in filtered entries.AttributeFilterincludeAttribute(AttributeDescription attributeDescription)Specifies that the named attribute should be included in filtered entries.AttributeFiltermapAttributes(Function<Attribute,Attribute> mapper)Registers a mapping function which should be applied to attributes selected by this attribute filter.booleanmatchesAllAttributes()Returnstrueif this attribute filter matches all attributes, regardless of whether they are user or operational attributes.booleanmatchesAllOperationalAttributes()Returnstrueif this attribute filter matches all operational attributes.booleanmatchesAllUserAttributes()Returnstrueif this attribute filter matches all user attributes.booleanmatchesAnyAttributes()Returnstrueif this attribute filter may match some attributes, orfalseif it will never match any attributes.booleanmatchesAttribute(AttributeDescription attributeDescription)Returnstrueif this attribute filter matches the provided attribute description.StringtoString()AttributeFiltertypesOnly(boolean typesOnly)Specifies whether filtered attributes are to contain both attribute descriptions and values, or just attribute descriptions.
-
-
-
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.
-
filteredCopyOf
public SearchResultEntry filteredCopyOf(SearchResultEntry entry)
Returns a modifiable filtered copy of the provided search result entry.- Parameters:
entry- The search result entry to be filtered and copied.- Returns:
- The modifiable filtered copy of the provided search result 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 its contents.- Parameters:
entry- The entry to be filtered.- Returns:
- The unmodifiable filtered view of the provided entry.
-
filteredViewOf
public SearchResultEntry filteredViewOf(SearchResultEntry entry)
Returns an unmodifiable filtered view of the provided search result entry. The returned search result entry supports all operations except those which modify its contents.- Parameters:
entry- The search result entry to be filtered.- Returns:
- The unmodifiable filtered view of the provided search result 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-trueif 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-trueif 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-trueif attribute expansion from object classes using the '@OC' syntax should also include attributes from superior classes in the list of requested attributes;falseotherwise.- 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 andfilterpredicates will be applied in registration order and may returnnullindicating 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 returnnullif 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 returntrueif the attribute should be included in the filtered entry.Mappingfunctions 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 returntrueif the attribute should be included in the filtered entry.- Returns:
- A reference to this attribute filter.
- See Also:
mapAttributes(Function)
-
matchesAllAttributes
public boolean matchesAllAttributes()
Returnstrueif this attribute filter matches all attributes, regardless of whether they are user or operational attributes.- Returns:
trueif this attribute filter matches all attributes.
-
matchesAllUserAttributes
public boolean matchesAllUserAttributes()
Returnstrueif this attribute filter matches all user attributes.- Returns:
trueif this attribute filter matches all user attributes.
-
matchesAllOperationalAttributes
public boolean matchesAllOperationalAttributes()
Returnstrueif this attribute filter matches all operational attributes.- Returns:
trueif this attribute filter matches all operational attributes.
-
matchesAnyAttributes
public boolean matchesAnyAttributes()
Returnstrueif this attribute filter may match some attributes, orfalseif it will never match any attributes.- Returns:
trueif this attribute filter may match some attributes.
-
matchesAttribute
public boolean matchesAttribute(AttributeDescription attributeDescription)
Returnstrueif this attribute filter matches the provided attribute description.- Parameters:
attributeDescription- The attribute description.- Returns:
trueif 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-trueif only attribute descriptions (and not values) are to be included, orfalse(the default) if both attribute descriptions and values are to be included.- Returns:
- A reference to this attribute filter.
-
-