Package io.jans.scim.model.scim2.util
Class ResourceValidator
- java.lang.Object
-
- io.jans.scim.model.scim2.util.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 Summary
Constructors Constructor Description ResourceValidator(BaseScimResource resource, List<Extension> extensions)Construct a instance of this class
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidvalidateCanonicalizedAttributes()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.voidvalidateExtendedAttributes()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.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).voidvalidateSchemasAttribute()Inspects theschemasattribute of the resource passed in the constructor and checks the default schemaurnassociated to the resource type is present in the list.voidvalidateValidableAttributes()Inspects the resource passed in the constructor and applies validations for every attribute annotated withValidator.
-
-
-
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 SCIMExceptionInspects 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
public void validateValidableAttributes() throws SCIMExceptionInspects 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
public void validateCanonicalizedAttributes() throws SCIMExceptionInspects 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
#validateRequiredAttributes().- Throws:
SCIMException- When a validation does not pass (there is no match for any of the attributes inspected)
-
validateSchemasAttribute
public void validateSchemasAttribute() throws SCIMExceptionInspects 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
#validateRequiredAttributes().- Throws:
SCIMException- If there is noschemasin this resource or if some of theurns there are not known.
-
validateExtendedAttributes
public void validateExtendedAttributes() throws SCIMExceptionInspects 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.
-
-