com.unboundid.ldap.sdk.schema
Class EntryValidator

java.lang.Object
  extended by com.unboundid.ldap.sdk.schema.EntryValidator
All Implemented Interfaces:
java.io.Serializable

@ThreadSafety(level=MOSTLY_THREADSAFE)
public final class EntryValidator
extends java.lang.Object
implements java.io.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:

All of these forms of validation will be performed by default, but individual types of validation may be enabled or disabled.

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) 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:
Serialized Form

Constructor Summary
EntryValidator(Schema schema)
          Creates a new entry validator that will validate entries according to the provided schema.
 
Method Summary
 boolean checkAttributeSyntax()
          Indicates whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.
 boolean checkMalformedDNs()
          Indicates whether the entry validator should consider entries invalid if their DNs cannot be parsed.
 boolean 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.
 boolean checkMissingSuperiorObjectClasses()
          Indicates whether the entry validator should consider entries invalid if they are missing any superior classes for the included set of object classes.
 boolean 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.
 boolean 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.
 boolean 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.
 boolean 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.
 boolean 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).
 boolean checkUndefinedAttributes()
          Indicates whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.
 boolean checkUndefinedObjectClasses()
          Indicates whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.
 boolean entryIsValid(Entry entry, java.util.List<java.lang.String> invalidReasons)
          Indicates whether the provided entry passes all of the enabled types of validation.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 long getEntriesExamined()
          Retrieves the total number of entries examined during processing.
 long getEntriesMissingStructuralObjectClass()
          Retrieves the total number of entries examined which did not contain any structural object class.
 long getEntriesWithMissingSuperiorObjectClasses()
          Retrieves the total number of entries examined which were missing one or more superior object classes.
 long getEntriesWithMultipleStructuralObjectClasses()
          Retrieves the total number of entries examined which contained more than one structural object class.
 long getEntriesWithoutAnyObjectClasses()
          Retrieves the total number of entries examined which did not contain any object classes.
 long getInvalidEntries()
          Retrieves the total number of invalid entries encountered during processing.
 java.util.List<java.lang.String> getInvalidEntrySummary(boolean detailedResults)
          Retrieves a list of messages providing a summary of the invalid entries processed by this class.
 long getMalformedDNs()
          Retrieves the total number of entries examined that had malformed DNs which could not be parsed.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 long getNameFormViolations()
          Retrieves the total number of entries examined which contained an RDN that violated the constraints of the associated name form.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 long getTotalAttributesViolatingSyntax()
          Retrieves the total number of attribute values which violate their associated syntax that were encountered while examining entries.
 long getTotalMissingAttributes()
          Retrieves the total number of missing required attributes encountered while examining entries.
 long getTotalProhibitedAttributes()
          Retrieves the total number of prohibited attributes encountered while examining entries.
 long getTotalProhibitedObjectClasses()
          Retrieves the total number of prohibited object classes encountered while examining entries.
 long getTotalSingleValueViolations()
          Retrieves the total number of attributes defined as single-valued that contained multiple values which were encountered while processing entries.
 long getTotalUndefinedAttributes()
          Retrieves the total number of undefined attribute types encountered while examining entries.
 long getTotalUndefinedObjectClasses()
          Retrieves the total number of undefined object classes encountered while examining entries.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 java.util.Map<java.lang.String,java.lang.Long> 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.
 void resetCounts()
          Resets all counts maintained by this entry validator.
 void setCheckAttributeSyntax(boolean checkAttributeSyntax)
          Specifies whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.
 void setCheckMalformedDNs(boolean checkMalformedDNs)
          Specifies whether the entry validator should consider entries invalid if their DNs cannot be parsed.
 void setCheckMissingAttributes(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.
 void setCheckMissingSuperiorObjectClasses(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.
 void setCheckNameForms(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.
 void setCheckProhibitedAttributes(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.
 void setCheckProhibitedObjectClasses(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.
 void setCheckSingleValuedAttributes(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.
 void setCheckStructuralObjectClasses(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).
 void setCheckUndefinedAttributes(boolean checkUndefinedAttributes)
          Specifies whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.
 void setCheckUndefinedObjectClasses(boolean checkUndefinedObjectClasses)
          Specifies whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntryValidator

public EntryValidator(Schema schema)
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 Detail

checkMissingAttributes

public boolean 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:
true if entries that are missing attributes required by its object classes or DIT content rule should be considered invalid, or false if not.

setCheckMissingAttributes

public void setCheckMissingAttributes(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.

Parameters:
checkMissingAttributes - Indicates whether the entry validator should consider entries invalid if they are missing required attributes.

checkMissingSuperiorObjectClasses

public boolean 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:
true if entries that are missing superior classes should be considered invalid, or false if not.

setCheckMissingSuperiorObjectClasses

public void setCheckMissingSuperiorObjectClasses(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.

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

public boolean checkMalformedDNs()
Indicates whether the entry validator should consider entries invalid if their DNs cannot be parsed.

Returns:
true if entries with malformed DNs should be considered invalid, or false if not.

setCheckMalformedDNs

public void setCheckMalformedDNs(boolean checkMalformedDNs)
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.

checkNameForms

public boolean 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:
true if entries with RDNs that do not conform to the associated name form should be considered invalid, or false if not.

setCheckNameForms

public void setCheckNameForms(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.

Parameters:
checkNameForms - Indicates whether the entry validator should consider entries invalid if their RDNs violate name form constraints.

checkProhibitedAttributes

public boolean 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:
true if entries should be considered invalid if they contain attributes which are not allowed, or false if not.

setCheckProhibitedAttributes

public void setCheckProhibitedAttributes(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.

Parameters:
checkProhibitedAttributes - Indicates whether entries should be considered invalid if they contain attributes which are not allowed.

checkProhibitedObjectClasses

public boolean 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:
true if entries should be considered invalid if they contain prohibited object classes, or false if not.

setCheckProhibitedObjectClasses

public void setCheckProhibitedObjectClasses(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.

Parameters:
checkProhibitedObjectClasses - Indicates whether entries should be considered invalid if they contain prohibited object classes.

checkSingleValuedAttributes

public boolean 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:
true if entries should be considered invalid if they contain single-valued attributes with more than one value, or false if not.

setCheckSingleValuedAttributes

public void setCheckSingleValuedAttributes(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.

Parameters:
checkSingleValuedAttributes - Indicates whether entries should be considered invalid if they contain single-valued attributes with more than one value.

checkStructuralObjectClasses

public boolean 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:
true if entries should be considered invalid if they do not have exactly one structural object class, or false if not.

setCheckStructuralObjectClasses

public void setCheckStructuralObjectClasses(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).

Parameters:
checkStructuralObjectClasses - Indicates whether entries should be considered invalid if they do not have exactly one structural object class.

checkAttributeSyntax

public boolean checkAttributeSyntax()
Indicates whether the entry validator should consider entries invalid if they contain attributes which violate the associated attribute syntax.

Returns:
true if entries should be considered invalid if they contain attribute values which violate the associated attribute syntax, or false if not.

setCheckAttributeSyntax

public void setCheckAttributeSyntax(boolean checkAttributeSyntax)
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.

checkUndefinedAttributes

public boolean checkUndefinedAttributes()
Indicates whether the entry validator should consider entries invalid if they contain attributes which are not defined in the schema.

Returns:
true if entries should be considered invalid if they contain attributes which are not defined in the schema, or false if not.

setCheckUndefinedAttributes

public void setCheckUndefinedAttributes(boolean checkUndefinedAttributes)
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, or false if not.

checkUndefinedObjectClasses

public boolean checkUndefinedObjectClasses()
Indicates whether the entry validator should consider entries invalid if they contain object classes which are not defined in the schema.

Returns:
true if entries should be considered invalid if they contain object classes which are not defined in the schema, or false if not.

setCheckUndefinedObjectClasses

public void setCheckUndefinedObjectClasses(boolean checkUndefinedObjectClasses)
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

public boolean entryIsValid(Entry entry,
                            java.util.List<java.lang.String> invalidReasons)
Indicates whether the provided entry passes all of the enabled types of validation.

Parameters:
entry - The entry to be examined. It must not be null.
invalidReasons - A list to which messages may be added which provide information about why the entry is invalid. It may be null if this information is not needed.
Returns:
true if the entry conforms to all of the enabled forms of validation, or false if the entry fails at least one of the tests.

resetCounts

public void resetCounts()
Resets all counts maintained by this entry validator.


getEntriesExamined

public long getEntriesExamined()
Retrieves the total number of entries examined during processing.

Returns:
The total number of entries examined during processing.

getInvalidEntries

public long getInvalidEntries()
Retrieves the total number of invalid entries encountered during processing.

Returns:
The total number of invalid entries encountered during processing.

getMalformedDNs

public long 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.

getEntriesWithoutAnyObjectClasses

public long 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

public long 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

public long 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

public long 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

public long 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public long 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

public java.util.Map<java.lang.String,java.lang.Long> 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

public java.util.List<java.lang.String> getInvalidEntrySummary(boolean detailedResults)
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.