Class ResourceValidator
java.lang.Object
org.gluu.oxtrust.model.scim2.util.ResourceValidator
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 Summary
ConstructorsConstructorDescriptionResourceValidator(BaseScimResource resource, List<Extension> extensions) Construct a instance of this class -
Method Summary
Modifier and TypeMethodDescriptionvoidInspects the resource passed in the constructor and for every attribute annotated with a non-empty collection ofcanonical values, it checks whether the attribute value matches any of the canonical values supplied.voidInspects the resource passed in the constructor and for every extended attribute (seeBaseScimResource.getCustomAttributes(), the attribute's value is checked to see if it complies with the data type it is supposed to belong to.voidvalidateRequiredAttributes(boolean laxRequiredness) Inspects the resource passed in the constructor and determines if the attributes annotated asrequiredin theClassof the resource were all provided (not null).voidInspects theschemasattribute of the resource passed in the constructor and checks the default schemaurnassociated to the resource type is present in the list.voidInspects the resource passed in the constructor and applies validations for every attribute annotated withValidator.
-
Constructor Details
-
ResourceValidator
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 Details
-
validateRequiredAttributes
Inspects the resource passed in the constructor and determines if the attributes annotated asrequiredin theClassof 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
Inspects the resource passed in the constructor and applies validations for every attribute annotated withValidator. Validations are of different nature as seenhere.- Throws:
SCIMException- When a validation does not pass (theapplymethod returns false)
-
validateCanonicalizedAttributes
Inspects the resource passed in the constructor and for every attribute annotated with a non-empty collection ofcanonical values, it checks whether the attribute value matches any of the canonical values supplied.This method should be called after a successful call to
.invalid reference
#validateRequiredAttributes()- Throws:
SCIMException- When a validation does not pass (there is no match for any of the attributes inspected)
-
validateSchemasAttribute
Inspects theschemasattribute of the resource passed in the constructor and checks the default schemaurnassociated to the resource type is present in the list. If some of theurns part of theExtensions passed in the constructor are contained in the list, the validation is also successful.This method should be called after a successful call to
.invalid reference
#validateRequiredAttributes()- Throws:
SCIMException- If there is noschemasin this resource or if some of theurns there are not known.
-
validateExtendedAttributes
Inspects the resource passed in the constructor and for every extended attribute (seeBaseScimResource.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 ofExtensions passed in the constructor (everyExtensionFieldhas an associatedtype.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.
-