Class ResourceValidator


  • public class ResourceValidator
    extends Object
    This class provides static methods to validate whether a (SCIM) resource instance fulfills certain characteristics - regarded to formatting, mutability, uniqueness, etc. This allows to adhere more closely to SCIM spec
    • Constructor Detail

      • ResourceValidator

        public ResourceValidator​(BaseScimResource resource,
                                 List<Extension> extensions)
        Construct a instance of this class
        Parameters:
        resource - A SCIM resource object (the target of validation)
        extensions - List of extensions associated to this resource
    • Method Detail

      • validateRequiredAttributes

        public void validateRequiredAttributes​(boolean laxRequiredness)
                                        throws SCIMException
        Inspects the resource passed in the constructor and determines if the attributes annotated as required in the Class of the resource were all provided (not null). In lax mode, if an attribute was marked as "required" and is part of a multi-valued complex attribute, no validation takes place if the involved list is null or empty.
        Parameters:
        laxRequiredness - True denotes lax mode, False normal validation mode (strict)
        Throws:
        SCIMException - When a validation does not pass (there is a missing value in a required attribute)
      • validateValidableAttributes

        public void validateValidableAttributes()
                                         throws SCIMException
        Inspects the resource passed in the constructor and applies validations for every attribute annotated with Validator. Validations are of different nature as seenhere.
        Throws:
        SCIMException - When a validation does not pass (the apply method returns false)
      • validateCanonicalizedAttributes

        public void validateCanonicalizedAttributes()
                                             throws SCIMException
        Inspects the resource passed in the constructor and for every attribute annotated with a non-empty collection of canonical values, it checks whether the attribute value matches any of the canonical values supplied.

        This method should be called after a successful call to #validateRequiredAttributes().

        Throws:
        SCIMException - When a validation does not pass (there is no match for any of the attributes inspected)
      • validateSchemasAttribute

        public void validateSchemasAttribute()
                                      throws SCIMException
        Inspects the schemas attribute of the resource passed in the constructor and checks the default schema urn associated to the resource type is present in the list. If some of the urns part of the Extensions passed in the constructor are contained in the list, the validation is also successful.

        This method should be called after a successful call to #validateRequiredAttributes().

        Throws:
        SCIMException - If there is no schemas in this resource or if some of the urns there are not known.
      • validateExtendedAttributes

        public void validateExtendedAttributes()
                                        throws SCIMException
        Inspects the resource passed in the constructor and for every extended attribute (see BaseScimResource.getCustomAttributes(), the attribute's value is checked to see if it complies with the data type it is supposed to belong to. This information is obtained from the list of Extensions passed in the constructor (every ExtensionField has an associated type.

        When an attribute is multi-valued, every single item inside the collection is validated.

        Throws:
        SCIMException - When any of the validations do not pass or an attribute seems not to be part of a known schema.