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. AnAttributeFilter
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 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 AttributeFilter
allUserAndOperationalAttributesFilter()
Creates a new attribute filter which will include all user and operational attributes.AttributeFilter
filterAttributes(Predicate<Attribute> filter)
Registers a predicate which should be applied to attributes selected by this attribute filter.Entry
filteredCopyOf(Entry entry)
Returns a modifiable filtered copy of the provided entry.Entry
filteredViewOf(Entry entry)
Returns an unmodifiable filtered view of the provided entry.AttributeFilter
includeAllOperationalAttributes(boolean include)
Specifies whether all operational attributes should be included in filtered entries.AttributeFilter
includeAllUserAttributes(boolean include)
Specifies whether all user attributes should be included in filtered entries.AttributeFilter
includeAttribute(String attributeDescription)
Specifies that the named attribute should be included in filtered entries.AttributeFilter
includeAttribute(String attributeDescription, Schema schema)
Specifies that the named attribute should be included in filtered entries.AttributeFilter
includeAttribute(String attributeDescription, Schema schema, boolean includeAttributesFromSuperiors)
Specifies that the named attribute should be included in filtered entries.AttributeFilter
includeAttribute(AttributeDescription attributeDescription)
Specifies that the named attribute should be included in filtered entries.AttributeFilter
mapAttributes(Function<Attribute,Attribute> mapper)
Registers a mapping function which should be applied to attributes selected by this attribute filter.boolean
matchesAllAttributes()
Returnstrue
if this attribute filter matches all attributes, regardless of whether they are user or operational attributes.boolean
matchesAllOperationalAttributes()
Returnstrue
if this attribute filter matches all operational attributes.boolean
matchesAllUserAttributes()
Returnstrue
if this attribute filter matches all user attributes.boolean
matchesAnyAttributes()
Returnstrue
if this attribute filter may match some attributes, orfalse
if it will never match any attributes.boolean
matchesAttribute(AttributeDescription attributeDescription)
Returnstrue
if this attribute filter matches the provided attribute description.String
toString()
AttributeFilter
typesOnly(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.
-
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 andfilter
predicates will be applied in registration order and may returnnull
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 returnnull
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 returntrue
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 returntrue
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()
Returnstrue
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()
Returnstrue
if this attribute filter matches all user attributes.- Returns:
true
if this attribute filter matches all user attributes.
-
matchesAllOperationalAttributes
public boolean matchesAllOperationalAttributes()
Returnstrue
if this attribute filter matches all operational attributes.- Returns:
true
if this attribute filter matches all operational attributes.
-
matchesAnyAttributes
public boolean matchesAnyAttributes()
Returnstrue
if this attribute filter may match some attributes, orfalse
if it will never match any attributes.- Returns:
true
if this attribute filter may match some attributes.
-
matchesAttribute
public boolean matchesAttribute(AttributeDescription attributeDescription)
Returnstrue
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, orfalse
(the default) if both attribute descriptions and values are to be included.- Returns:
- A reference to this attribute filter.
-
-