Package com.unboundid.ldap.sdk.schema
Class EntryValidator
java.lang.Object
com.unboundid.ldap.sdk.schema.EntryValidator
- All Implemented Interfaces:
Serializable
@ThreadSafety(level=MOSTLY_THREADSAFE)
public final class EntryValidator
extends Object
implements Serializable
This class provides a mechanism for validating entries against a schema. It
provides the ability to customize the types of validation to perform, and can
collect information about the entries that fail validation to provide a
summary of the problems encountered.
The types of validation that may be performed for each entry include:
This class will not make any attempt to validate compliance with DIT structure rules, nor will it check the OBSOLETE field for any of the schema elements. In addition, attempts to validate whether attribute values conform to the syntax for the associated attribute type may only be completely accurate for syntaxes supported by the LDAP SDK.
This class is largely threadsafe, and the
The types of validation that may be performed for each entry include:
- Ensure that the entry has a valid DN.
- Ensure that all attribute values used in the entry's RDN are also present in the entry.
- Ensure that the entry has exactly one structural object class.
- Ensure that all of the object classes for the entry are defined in the schema.
- Ensure that all of the auxiliary classes for the entry are allowed by the DIT content rule for the entry's structural object class (if such a DIT content rule is defined).
- Ensure that all attributes contained in the entry are defined in the schema.
- Ensure that all attributes required by the entry's object classes or DIT content rule (if defined) are present in the entry.
- Ensure that all of the user attributes contained in the entry are allowed by the entry's object classes or DIT content rule (if defined).
- Ensure that all attribute values conform to the requirements of the associated attribute syntax.
- Ensure that all attributes with multiple values are defined as multi-valued in the associated schema.
- If there is a name form associated with the entry's structural object class, then ensure that the entry's RDN satisfies its constraints.
This class will not make any attempt to validate compliance with DIT structure rules, nor will it check the OBSOLETE field for any of the schema elements. In addition, attempts to validate whether attribute values conform to the syntax for the associated attribute type may only be completely accurate for syntaxes supported by the LDAP SDK.
This class is largely threadsafe, and the
entryIsValid(com.unboundid.ldap.sdk.Entry, java.util.List<java.lang.String>)
is designed so that it can be invoked concurrently by multiple threads.
Note, however, that it is not recommended that the any of the other methods
in this class be used while any threads are running the entryIsValid
method because changing the configuration or attempting to retrieve retrieve
information may yield inaccurate or inconsistent results.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEntryValidator(Schema schema) Creates a new entry validator that will validate entries according to the provided schema. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.booleanIndicates whether the entry validator should consider entries invalid if they contain one or more attribute values in their RDN that are not present in the set of entry attributes.booleanIndicates whether the entry validator should consider entries invalid if their DNs cannot be parsed.booleanIndicates whether the entry validator should consider entries invalid if they are missing attributes which are required by the object classes or DIT content rule (if applicable) for the entry.booleanIndicates whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.booleanIndicates whether the entry validator should consider entries invalid if the attributes contained in the RDN violate the constraints of the associated name form.booleanIndicates whether the entry validator should consider entries invalid if they contain attributes which are not allowed by (or are prohibited by) the object classes and DIT content rule (if applicable) for the entry.booleanIndicates whether the entry validator should consider entries invalid if they contain auxiliary object classes which are not allowed by the DIT content rule (if applicable) for the entry, or if they contain any abstract object classes which are not subclassed by any non-abstract classes included in the entry.booleanIndicates whether the entry validator should consider entries invalid if they they contain attributes with more than one value which are declared as single-valued in the schema.booleanIndicates whether the entry validator should consider entries invalid if they do not contain exactly one structural object class (i.e., either do not have any structural object class, or have more than one).booleanIndicates whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.booleanIndicates whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.booleanentryIsValid(Entry entry, List<String> invalidReasons) Indicates whether the provided entry passes all of the enabled types of validation.Retrieves the attributes with values violating their associated syntax that were encountered while processing entries, mapped from the name of the attribute to the number of malformed values found for that attribute.longRetrieves the total number of entries examined during processing.longRetrieves the total number of entries examined that included an attribute value in the RDN that was not present in the entry attributes.longRetrieves the total number of entries examined which did not contain any structural object class.longRetrieves the total number of entries examined which were missing one or more superior object classes.longRetrieves the total number of entries examined which contained more than one structural object class.longRetrieves the total number of entries examined which did not contain any object classes.Retrieves the set of attribute types for which syntax violations should be ignored.longRetrieves the total number of invalid entries encountered during processing.getInvalidEntrySummary(boolean detailedResults) Retrieves a list of messages providing a summary of the invalid entries processed by this class.longRetrieves the total number of entries examined that had malformed DNs which could not be parsed.Retrieves the missing required encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute was required but not found.longRetrieves the total number of entries examined which contained an RDN that violated the constraints of the associated name form.Retrieves the prohibited attributes encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute was referenced.Retrieves the prohibited object classes encountered while processing entries, mapped from the name of the object class to the number of entries in which that object class was referenced.Retrieves the attributes defined as single-valued that contained multiple values which were encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute had multiple values.longRetrieves the total number of attribute values which violate their associated syntax that were encountered while examining entries.longRetrieves the total number of missing required attributes encountered while examining entries.longRetrieves the total number of prohibited attributes encountered while examining entries.longRetrieves the total number of prohibited object classes encountered while examining entries.longRetrieves the total number of attributes defined as single-valued that contained multiple values which were encountered while processing entries.longRetrieves the total number of undefined attribute types encountered while examining entries.longRetrieves the total number of undefined object classes encountered while examining entries.Retrieves the undefined attribute types encountered while processing entries, mapped from the name of the undefined attribute to the number of entries in which that attribute type was referenced.Retrieves the undefined object classes encountered while processing entries, mapped from the name of the undefined object class to the number of entries in which that object class was referenced.voidResets all counts maintained by this entry validator.voidsetCheckAttributeSyntax(boolean checkAttributeSyntax) Specifies whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.voidsetCheckEntryMissingRDNValues(boolean checkEntryMissingRDNValues) Specifies whether the entry validator should consider entries invalid if they contain one or more attribute values in their RDN that are not present in the set of entry attributes.voidsetCheckMalformedDNs(boolean checkMalformedDNs) Specifies whether the entry validator should consider entries invalid if their DNs cannot be parsed.voidsetCheckMissingAttributes(boolean checkMissingAttributes) Specifies whether the entry validator should consider entries invalid if they are missing attributes which are required by the object classes or DIT content rule (if applicable) for the entry.voidsetCheckMissingSuperiorObjectClasses(boolean checkMissingSuperiorObjectClasses) Specifies whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.voidsetCheckNameForms(boolean checkNameForms) Specifies whether the entry validator should consider entries invalid if the attributes contained in the RDN violate the constraints of the associated name form.voidsetCheckProhibitedAttributes(boolean checkProhibitedAttributes) Specifies whether the entry validator should consider entries invalid if they contain attributes which are not allowed by (or are prohibited by) the object classes and DIT content rule (if applicable) for the entry.voidsetCheckProhibitedObjectClasses(boolean checkProhibitedObjectClasses) Specifies whether the entry validator should consider entries invalid if they contain auxiliary object classes which are not allowed by the DIT content rule (if applicable) for the entry, or if they contain any abstract object classes which are not subclassed by any non-abstract classes included in the entry.voidsetCheckSingleValuedAttributes(boolean checkSingleValuedAttributes) Specifies whether the entry validator should consider entries invalid if they contain attributes with more than one value which are declared as single-valued in the schema.voidsetCheckStructuralObjectClasses(boolean checkStructuralObjectClasses) Specifies whether the entry validator should consider entries invalid if they do not contain exactly one structural object class (i.e., either do not have any structural object class, or have more than one).voidsetCheckUndefinedAttributes(boolean checkUndefinedAttributes) Specifies whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.voidsetCheckUndefinedObjectClasses(boolean checkUndefinedObjectClasses) Specifies whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.voidsetIgnoreSyntaxViolationAttributeTypes(AttributeTypeDefinition... attributeTypes) Specifies the set of attribute types for which syntax violations should be ignored.voidsetIgnoreSyntaxViolationAttributeTypes(String... attributeTypes) Specifies the names or OIDs of the attribute types for which syntax violations should be ignored.voidsetIgnoreSyntaxViolationAttributeTypes(Collection<String> attributeTypes) Specifies the names or OIDs of the attribute types for which syntax violations should be ignored.
-
Constructor Details
-
EntryValidator
Creates a new entry validator that will validate entries according to the provided schema.- Parameters:
schema- The schema against which entries will be validated.
-
-
Method Details
-
checkMissingAttributes
Indicates whether the entry validator should consider entries invalid if they are missing attributes which are required by the object classes or DIT content rule (if applicable) for the entry.- Returns:
trueif entries that are missing attributes required by its object classes or DIT content rule should be considered invalid, orfalseif not.
-
setCheckMissingAttributes
Specifies whether the entry validator should consider entries invalid if they are missing attributes which are required by the object classes or DIT content rule (if applicable) for the entry.- Parameters:
checkMissingAttributes- Indicates whether the entry validator should consider entries invalid if they are missing required attributes.
-
checkMissingSuperiorObjectClasses
Indicates whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.- Returns:
trueif entries that are missing superior classes should be considered invalid, orfalseif not.
-
setCheckMissingSuperiorObjectClasses
Specifies whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.- Parameters:
checkMissingSuperiorObjectClasses- Indicates whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.
-
checkMalformedDNs
Indicates whether the entry validator should consider entries invalid if their DNs cannot be parsed.- Returns:
trueif entries with malformed DNs should be considered invalid, orfalseif not.
-
setCheckMalformedDNs
Specifies whether the entry validator should consider entries invalid if their DNs cannot be parsed.- Parameters:
checkMalformedDNs- Specifies whether entries with malformed DNs should be considered invalid.
-
checkEntryMissingRDNValues
Indicates whether the entry validator should consider entries invalid if they contain one or more attribute values in their RDN that are not present in the set of entry attributes.- Returns:
trueif entries missing one or more attribute values included in their RDNs should be considered invalid, orfalseif not.
-
setCheckEntryMissingRDNValues
Specifies whether the entry validator should consider entries invalid if they contain one or more attribute values in their RDN that are not present in the set of entry attributes.- Parameters:
checkEntryMissingRDNValues- Indicates whether the entry validator should consider entries invalid if they contain one or more attribute values in their RDN that are not present in the set of entry attributes.
-
checkNameForms
Indicates whether the entry validator should consider entries invalid if the attributes contained in the RDN violate the constraints of the associated name form.- Returns:
trueif entries with RDNs that do not conform to the associated name form should be considered invalid, orfalseif not.
-
setCheckNameForms
Specifies whether the entry validator should consider entries invalid if the attributes contained in the RDN violate the constraints of the associated name form.- Parameters:
checkNameForms- Indicates whether the entry validator should consider entries invalid if their RDNs violate name form constraints.
-
checkProhibitedAttributes
Indicates whether the entry validator should consider entries invalid if they contain attributes which are not allowed by (or are prohibited by) the object classes and DIT content rule (if applicable) for the entry.- Returns:
trueif entries should be considered invalid if they contain attributes which are not allowed, orfalseif not.
-
setCheckProhibitedAttributes
Specifies whether the entry validator should consider entries invalid if they contain attributes which are not allowed by (or are prohibited by) the object classes and DIT content rule (if applicable) for the entry.- Parameters:
checkProhibitedAttributes- Indicates whether entries should be considered invalid if they contain attributes which are not allowed.
-
checkProhibitedObjectClasses
Indicates whether the entry validator should consider entries invalid if they contain auxiliary object classes which are not allowed by the DIT content rule (if applicable) for the entry, or if they contain any abstract object classes which are not subclassed by any non-abstract classes included in the entry.- Returns:
trueif entries should be considered invalid if they contain prohibited object classes, orfalseif not.
-
setCheckProhibitedObjectClasses
Specifies whether the entry validator should consider entries invalid if they contain auxiliary object classes which are not allowed by the DIT content rule (if applicable) for the entry, or if they contain any abstract object classes which are not subclassed by any non-abstract classes included in the entry.- Parameters:
checkProhibitedObjectClasses- Indicates whether entries should be considered invalid if they contain prohibited object classes.
-
checkSingleValuedAttributes
Indicates whether the entry validator should consider entries invalid if they they contain attributes with more than one value which are declared as single-valued in the schema.- Returns:
trueif entries should be considered invalid if they contain single-valued attributes with more than one value, orfalseif not.
-
setCheckSingleValuedAttributes
Specifies whether the entry validator should consider entries invalid if they contain attributes with more than one value which are declared as single-valued in the schema.- Parameters:
checkSingleValuedAttributes- Indicates whether entries should be considered invalid if they contain single-valued attributes with more than one value.
-
checkStructuralObjectClasses
Indicates whether the entry validator should consider entries invalid if they do not contain exactly one structural object class (i.e., either do not have any structural object class, or have more than one).- Returns:
trueif entries should be considered invalid if they do not have exactly one structural object class, orfalseif not.
-
setCheckStructuralObjectClasses
Specifies whether the entry validator should consider entries invalid if they do not contain exactly one structural object class (i.e., either do not have any structural object class, or have more than one).- Parameters:
checkStructuralObjectClasses- Indicates whether entries should be considered invalid if they do not have exactly one structural object class.
-
checkAttributeSyntax
Indicates whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.- Returns:
trueif entries should be considered invalid if they contain attribute values which violate the associated attribute syntax, orfalseif not.
-
setCheckAttributeSyntax
Specifies whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.- Parameters:
checkAttributeSyntax- Indicates whether entries should be considered invalid if they violate the associated attribute syntax.
-
getIgnoreSyntaxViolationsAttributeTypes
Retrieves the set of attribute types for which syntax violations should be ignored. IfcheckAttributeSyntax()returnstrue, then any attribute syntax violations will be flagged for all attributes except those attributes in this set. IfcheckAttributeSyntax()returnsfalse, then all syntax violations will be ignored.- Returns:
- The set of attribute types for which syntax violations should be ignored.
-
setIgnoreSyntaxViolationAttributeTypes
public void setIgnoreSyntaxViolationAttributeTypes(@Nullable AttributeTypeDefinition... attributeTypes) Specifies the set of attribute types for which syntax violations should be ignored. This method will only have any effect ifcheckAttributeSyntax()returnstrue.- Parameters:
attributeTypes- The definitions for the attribute types for which to ignore syntax violations. It may benullor empty if no violations should be ignored.
-
setIgnoreSyntaxViolationAttributeTypes
Specifies the names or OIDs of the attribute types for which syntax violations should be ignored. This method will only have any effect ifcheckAttributeSyntax()returnstrue.- Parameters:
attributeTypes- The names or OIDs of the attribute types for which to ignore syntax violations. It may benullor empty if no violations should be ignored.
-
setIgnoreSyntaxViolationAttributeTypes
Specifies the names or OIDs of the attribute types for which syntax violations should be ignored. This method will only have any effect ifcheckAttributeSyntax()returnstrue.- Parameters:
attributeTypes- The names or OIDs of the attribute types for which to ignore syntax violations. It may benullor empty if no violations should be ignored. Any attribute types not defined in the schema will be ignored.
-
checkUndefinedAttributes
Indicates whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.- Returns:
trueif entries should be considered invalid if they contain attributes which are not defined in the schema, orfalseif not.
-
setCheckUndefinedAttributes
Specifies whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.- Parameters:
checkUndefinedAttributes- Indicates whether entries should be considered invalid if they contain attributes which are not defined in the schema, orfalseif not.
-
checkUndefinedObjectClasses
Indicates whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.- Returns:
trueif entries should be considered invalid if they contain object classes which are not defined in the schema, orfalseif not.
-
setCheckUndefinedObjectClasses
Specifies whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.- Parameters:
checkUndefinedObjectClasses- Indicates whether entries should be considered invalid if they contain object classes which are not defined in the schema.
-
entryIsValid
Indicates whether the provided entry passes all of the enabled types of validation.- Parameters:
entry- The entry to be examined. It must not benull.invalidReasons- A list to which messages may be added which provide information about why the entry is invalid. It may benullif this information is not needed.- Returns:
trueif the entry conforms to all of the enabled forms of validation, orfalseif the entry fails at least one of the tests.
-
resetCounts
Resets all counts maintained by this entry validator. -
getEntriesExamined
Retrieves the total number of entries examined during processing.- Returns:
- The total number of entries examined during processing.
-
getInvalidEntries
Retrieves the total number of invalid entries encountered during processing.- Returns:
- The total number of invalid entries encountered during processing.
-
getMalformedDNs
Retrieves the total number of entries examined that had malformed DNs which could not be parsed.- Returns:
- The total number of entries examined that had malformed DNs.
-
getEntriesMissingRDNValues
Retrieves the total number of entries examined that included an attribute value in the RDN that was not present in the entry attributes.- Returns:
- The total number of entries examined that included an attribute value in the RDN that was not present in the entry attributes.
-
getEntriesWithoutAnyObjectClasses
Retrieves the total number of entries examined which did not contain any object classes.- Returns:
- The total number of entries examined which did not contain any object classes.
-
getEntriesMissingStructuralObjectClass
Retrieves the total number of entries examined which did not contain any structural object class.- Returns:
- The total number of entries examined which did not contain any structural object class.
-
getEntriesWithMultipleStructuralObjectClasses
Retrieves the total number of entries examined which contained more than one structural object class.- Returns:
- The total number of entries examined which contained more than one structural object class.
-
getEntriesWithMissingSuperiorObjectClasses
Retrieves the total number of entries examined which were missing one or more superior object classes.- Returns:
- The total number of entries examined which were missing one or more superior object classes.
-
getNameFormViolations
Retrieves the total number of entries examined which contained an RDN that violated the constraints of the associated name form.- Returns:
- The total number of entries examined which contained an RDN that violated the constraints of the associated name form.
-
getTotalUndefinedObjectClasses
Retrieves the total number of undefined object classes encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries contain multiple undefined object classes.- Returns:
- The total number of undefined object classes encountered while examining entries.
-
getUndefinedObjectClasses
Retrieves the undefined object classes encountered while processing entries, mapped from the name of the undefined object class to the number of entries in which that object class was referenced.- Returns:
- The undefined object classes encountered while processing entries.
-
getTotalUndefinedAttributes
Retrieves the total number of undefined attribute types encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries contain multiple undefined attribute types.- Returns:
- The total number of undefined attribute types encountered while examining entries.
-
getUndefinedAttributes
Retrieves the undefined attribute types encountered while processing entries, mapped from the name of the undefined attribute to the number of entries in which that attribute type was referenced.- Returns:
- The undefined attribute types encountered while processing entries.
-
getTotalProhibitedObjectClasses
Retrieves the total number of prohibited object classes encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries contain multiple prohibited object classes.- Returns:
- The total number of prohibited object classes encountered while examining entries.
-
getProhibitedObjectClasses
Retrieves the prohibited object classes encountered while processing entries, mapped from the name of the object class to the number of entries in which that object class was referenced.- Returns:
- The prohibited object classes encountered while processing entries.
-
getTotalProhibitedAttributes
Retrieves the total number of prohibited attributes encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries contain multiple prohibited attributes.- Returns:
- The total number of prohibited attributes encountered while examining entries.
-
getProhibitedAttributes
Retrieves the prohibited attributes encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute was referenced.- Returns:
- The prohibited attributes encountered while processing entries.
-
getTotalMissingAttributes
Retrieves the total number of missing required attributes encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries are missing multiple attributes.- Returns:
- The total number of missing required attributes encountered while examining entries.
-
getMissingAttributes
Retrieves the missing required encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute was required but not found.- Returns:
- The prohibited attributes encountered while processing entries.
-
getTotalAttributesViolatingSyntax
Retrieves the total number of attribute values which violate their associated syntax that were encountered while examining entries. Note that this number may be greater than the total number of entries examined if entries contain multiple malformed attribute values.- Returns:
- The total number of attribute values which violate their associated syntax that were encountered while examining entries.
-
getAttributesViolatingSyntax
Retrieves the attributes with values violating their associated syntax that were encountered while processing entries, mapped from the name of the attribute to the number of malformed values found for that attribute.- Returns:
- The attributes with malformed values encountered while processing entries.
-
getTotalSingleValueViolations
Retrieves the total number of attributes defined as single-valued that contained multiple values which were encountered while processing entries. Note that this number may be greater than the total number of entries examined if entries contain multiple such attributes.- Returns:
- The total number of attribute defined as single-valued that contained multiple values which were encountered while processing entries.
-
getSingleValueViolations
Retrieves the attributes defined as single-valued that contained multiple values which were encountered while processing entries, mapped from the name of the attribute to the number of entries in which that attribute had multiple values.- Returns:
- The attributes defined as single-valued that contained multiple values which were encountered while processing entries.
-
getInvalidEntrySummary
Retrieves a list of messages providing a summary of the invalid entries processed by this class.- Parameters:
detailedResults- Indicates whether to include detailed information about the attributes and object classes responsible for the violations.- Returns:
- A list of messages providing a summary of the invalid entries processed by this class, or an empty list if all entries examined were valid.
-