Class AbstractSchemaValidator

java.lang.Object
de.captaingoldfish.scim.sdk.server.schemas.validation.AbstractSchemaValidator
Direct Known Subclasses:
MetaSchemaValidator, RequestSchemaValidator, ResponseSchemaValidator

public abstract class AbstractSchemaValidator extends Object
Since:
23.04.2021
Author:
Pascal Knueppel
  • Field Details

    • resourceNodeType

      protected final Class resourceNodeType
  • Constructor Details

    • AbstractSchemaValidator

      public AbstractSchemaValidator(ServiceProvider serviceProvider, Class resourceNodeType)
  • Method Details

    • validateAttribute

      protected abstract Optional<com.fasterxml.jackson.databind.JsonNode> validateAttribute(SchemaAttribute schemaAttribute, com.fasterxml.jackson.databind.JsonNode attribute)
      the concrete attribute validation that is differs by the context in which the attribute is validated
      Parameters:
      schemaAttribute - the definition of the attribute that must be validated
      attribute - the attribute to validate
      Returns:
      the validated attribute
    • getHttpStatusCode

      protected abstract int getHttpStatusCode()
      the http status code to use in the DocumentValidationException if the validation fails. Should be 400 (bad request) for requests and 500 (internal server error) for responses
    • validateDocument

      public ScimObjectNode validateDocument(Schema schema, com.fasterxml.jackson.databind.JsonNode resource)
      checks the given document against the schema definition of the #resourceType
      Parameters:
      resource - the document that should be validated
      Returns:
      the validated resource
    • checkDocumentAndMetaSchemaRelationship

      protected com.fasterxml.jackson.databind.JsonNode checkDocumentAndMetaSchemaRelationship(Schema resourceSchema, com.fasterxml.jackson.databind.JsonNode document)
      this method will verify that the meta schema is the correct schema to validate the document. This is done by comparing the "id"-attribute of the metaSchema with the "schemas"-attribute of the document
      Parameters:
      resourceSchema - the resources schema that should be used to validate the document
      document - the document that should be validated
    • validateDocument

      protected ScimObjectNode validateDocument(ScimObjectNode validatedResource, Schema resourceSchema, com.fasterxml.jackson.databind.JsonNode resource)
      this method will validate either a resource document or an extension document that is part of the resource document. Extensions are handled as individual schemas.
      Parameters:
      validatedResource - The object into which the validated attributes will be added. In case of main document validation this object will be of type ResourceNode and in case of extension validation of type ScimObjectNode
      resourceSchema - the definition of the document that is either the main schema of the #resourceType of an extension that is present within the current document
      resource - the document that should be validated
      Returns:
      the validated document with its scim attribute representations
    • getAttributeExtractor

      public AttributeExtractor getAttributeExtractor(com.fasterxml.jackson.databind.JsonNode resource)
      retrieves the attribute extractor that should be used based on the service providers configuration
      Parameters:
      resource - the resource that acts as the attribute extractors base document
      Returns:
      the attribute extractor to use. Default is the case-sensitive attribute extractor
    • getServiceProvider

      protected ServiceProvider getServiceProvider()
      the service provider configuration in order to check if case-insensitive attribute extraction is enabled or not