Class SchemaValidationPolicy


  • public final class SchemaValidationPolicy
    extends Object
    This class provides various schema validation policy options for controlling how entries should be validated against the directory schema.
    • Method Detail

      • copyOf

        public static SchemaValidationPolicy copyOf​(SchemaValidationPolicy policy)
        Creates a copy of the provided schema validation policy.
        Parameters:
        policy - The policy to be copied.
        Returns:
        The copy of the provided schema validation policy.
      • defaultPolicy

        public static SchemaValidationPolicy defaultPolicy()
        Creates a new schema validation policy with default settings. More specifically:
        • Entries not having a single structural object class will be rejected
        • Entries having attributes which are not permitted by its object classes or DIT content rule (if present) will be rejected
        • Entries not conforming to name forms will be rejected
        • DIT structure rules will not be ignored
        Returns:
        The new schema validation policy.
      • ignoreAll

        public static SchemaValidationPolicy ignoreAll()
        Creates a new schema validation policy which will not perform any schema validation.
        Returns:
        The new schema validation policy.
      • checkAttributesAndObjectClasses

        public SchemaValidationPolicy.Action checkAttributesAndObjectClasses()
        Returns the policy for verifying that the user attributes in an entry conform to its object classes. More specifically, an entry must contain all required user attributes, and must not contain any user attributes which are not declared as required or optional by its object classes.

        By default entries which have missing or additional user attributes will be rejected.

        Returns:
        The policy for verifying that the user attributes in an entry conform to its object classes.
      • checkAttributesAndObjectClasses

        public SchemaValidationPolicy checkAttributesAndObjectClasses​(SchemaValidationPolicy.Action policy)
        Specifies the policy for verifying that the user attributes in an entry conform to its object classes. More specifically, an entry must contain all required user attributes, and must not contain any user attributes which are not declared as required or optional by its object classes.

        By default entries which have missing or additional user attributes will be rejected.

        Parameters:
        policy - The policy for verifying that the user attributes in an entry conform to its object classes.
        Returns:
        A reference to this SchemaValidationPolicy.
      • checkAttributeValues

        public SchemaValidationPolicy.Action checkAttributeValues()
        Returns the policy for verifying that the user attributes in an entry conform to their associated attribute type descriptions. This may include:
        • checking that there is at least one value
        • checking that single-valued attributes contain only a single value
        • checking that there are no duplicate values according to the attribute's default equality matching rule
        • checking that attributes which require BER encoding specify the ;binary attribute option
        • checking that the values are valid according to the attribute's syntax.
        Schema validation implementations specify exactly which of the above checks will be performed.

        By default entries which have invalid attribute values will be rejected.

        Returns:
        The policy for verifying that the user attributes in an entry conform to their associated attribute type descriptions.
      • checkAttributeValues

        public SchemaValidationPolicy checkAttributeValues​(SchemaValidationPolicy.Action policy)
        Specifies the policy for verifying that the user attributes in an entry conform to their associated attribute type descriptions. This may include:
        • checking that there is at least one value
        • checking that single-valued attributes contain only a single value
        • checking that there are no duplicate values according to the attribute's default equality matching rule
        • checking that attributes which require BER encoding specify the ;binary attribute option
        • checking that the values are valid according to the attribute's syntax.
        Schema validation implementations specify exactly which of the above checks will be performed.

        By default entries which have invalid attribute values will be rejected.

        Parameters:
        policy - The policy for verifying that the user attributes in an entry conform to their associated attribute type descriptions.
        Returns:
        A reference to this SchemaValidationPolicy.
      • checkDitContentRules

        public SchemaValidationPolicy.Action checkDitContentRules()
        Returns the policy for validating entries against content rules defined in the schema.

        By default content rules will be ignored during validation.

        Returns:
        The policy for validating entries against content rules defined in the schema.
      • checkDitContentRules

        public SchemaValidationPolicy checkDitContentRules​(SchemaValidationPolicy.Action policy)
        Specifies the policy for validating entries against content rules defined in the schema.

        By default content rules will be ignored during validation.

        Parameters:
        policy - The policy for validating entries against content rules defined in the schema.
        Returns:
        A reference to this SchemaValidationPolicy.
      • checkDitStructureRules

        public SchemaValidationPolicy.Action checkDitStructureRules()
        Returns the policy for validating entries against structure rules defined in the schema.

        By default structure rules will be ignored during validation.

        Returns:
        The policy for validating entries against structure rules defined in the schema.
      • checkDitStructureRules

        public SchemaValidationPolicy checkDitStructureRules​(SchemaValidationPolicy.Action policy,
                                                             Function<Dn,​Entry,​LdapException> parentEntryResolver)
        Specifies the policy for validating entries against structure rules defined in the schema.

        By default structure rules will be ignored during validation.

        Parameters:
        policy - The policy for validating entries against structure rules defined in the schema.
        parentEntryResolver - The parent entry resolver function which should be used for retrieving the parent entry during DIT structure rule validation. The function's parameter is the name of the entry for which the parent must be resolved. The function will return the entry that is the parent of the provided entry name, if it can be be validated and was resolved successfully, otherwise it will return null if the parent entry is not to be validated, otherwise it will throw LdapException if the parent entry should be validated but it could not be resolved.
        Returns:
        A reference to this SchemaValidationPolicy.
        Throws:
        IllegalArgumentException - If resolver was null and checkDITStructureRules is either WARN or REJECT.
        See Also:
        checkDitStructureRulesParentEntryResolver()
      • checkDitStructureRulesParentEntryResolver

        public Function<Dn,​Entry,​LdapException> checkDitStructureRulesParentEntryResolver()
        Returns the parent entry resolver which should be used for retrieving the parent entry during DIT structure rule validation.

        By default no resolver is defined because structure rules will be ignored during validation.

        Returns:
        A function whose parameter is the name of the entry for which the parent must be resolved.
        See Also:
        's javadoc for a description of the function's contract.
      • checkNameForms

        public SchemaValidationPolicy.Action checkNameForms()
        Returns the policy for validating entries against name forms defined in the schema.

        By default name forms will be ignored during validation.

        Returns:
        The policy for validating entries against name forms defined in the schema.
      • checkNameForms

        public SchemaValidationPolicy checkNameForms​(SchemaValidationPolicy.Action policy)
        Specifies the policy for validating entries against name forms defined in the schema.

        By default name forms will be ignored during validation.

        Parameters:
        policy - The policy for validating entries against name forms defined in the schema.
        Returns:
        A reference to this SchemaValidationPolicy.
      • requireSingleStructuralObjectClass

        public SchemaValidationPolicy.Action requireSingleStructuralObjectClass()
        Returns the policy for verifying that entries have only a single structural object class.

        By default entries which do not have a structural object class or which have more than one structural object class will be rejected.

        Returns:
        The policy for checking that entries have one and only one structural object class.
      • requireSingleStructuralObjectClass

        public SchemaValidationPolicy requireSingleStructuralObjectClass​(SchemaValidationPolicy.Action policy)
        Specifies the policy for verifying that entries have only a single structural object class.

        By default entries which do not have a structural object class or which have more than one structural object class will be rejected.

        Parameters:
        policy - The policy for checking that entries have one and only one structural object class.
        Returns:
        A reference to this SchemaValidationPolicy.
      • adaptSchemaForValidation

        public Schema adaptSchemaForValidation​(Schema schema)
        Returns a strict view of the provided schema if the this policy is configured to check attributes and object class, or a non-strict view of the schema if not.
        Parameters:
        schema - The schema to be adapted according to this policy.
        Returns:
        A strict or non-strict view of schema depending on checkAttributesAndObjectClasses().