Class AbstractSchemaValidator
java.lang.Object
de.captaingoldfish.scim.sdk.server.schemas.validation.AbstractSchemaValidator
- Direct Known Subclasses:
MetaSchemaValidator,RequestSchemaValidator,ResponseSchemaValidator
- Since:
- 23.04.2021
- Author:
- Pascal Knueppel
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSchemaValidator(ServiceProvider serviceProvider, Class resourceNodeType) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.databind.JsonNodecheckDocumentAndMetaSchemaRelationship(Schema resourceSchema, com.fasterxml.jackson.databind.JsonNode document) this method will verify that the meta schema is the correct schema to validate the document.getAttributeExtractor(com.fasterxml.jackson.databind.JsonNode resource) retrieves the attribute extractor that should be used based on the service providers configurationprotected abstract intthe http status code to use in theDocumentValidationExceptionif the validation fails.protected ServiceProviderthe service provider configuration in order to check if case-insensitive attribute extraction is enabled or notprotected 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 validatedprotected ScimObjectNodevalidateDocument(ScimObjectNode validatedResource, Schema resourceSchema, com.fasterxml.jackson.databind.JsonNode resource) this method will validates either a resource document or an extension document that is part of the resource document.validateDocument(Schema schema, com.fasterxml.jackson.databind.JsonNode resource) checks the given document against the schema definition of the#resourceType
-
Field Details
-
resourceNodeType
-
-
Constructor Details
-
AbstractSchemaValidator
-
-
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 validatedattribute- the attribute to validate- Returns:
- the validated attribute
-
getHttpStatusCode
protected abstract int getHttpStatusCode()the http status code to use in theDocumentValidationExceptionif 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 documentdocument- the document that should be validated
-
validateDocument
protected ScimObjectNode validateDocument(ScimObjectNode validatedResource, Schema resourceSchema, com.fasterxml.jackson.databind.JsonNode resource) this method will validates 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 typeResourceNodeand in case of extension validation of typeScimObjectNoderesourceSchema- the definition of the document that is either the main schema of the#resourceTypeof an extension that is present within the current documentresource- the document that should be validated- Returns:
- the validated document with its scim attribute representations
-
getAttributeExtractor
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
the service provider configuration in order to check if case-insensitive attribute extraction is enabled or not
-