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 void
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.void
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.void
validateRequiredAttributes(boolean laxRequiredness)
Inspects the resource passed in the constructor and determines if the attributes annotated asrequired
in theClass
of the resource were all provided (not null).void
validateSchemasAttribute()
Inspects theschemas
attribute of the resource passed in the constructor and checks the default schemaurn
associated to the resource type is present in the list.void
validateValidableAttributes()
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 SCIMException
Inspects the resource passed in the constructor and determines if the attributes annotated asrequired
in theClass
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 withValidator
. Validations are of different nature as seenhere
.- Throws:
SCIMException
- When a validation does not pass (theapply
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 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 SCIMException
Inspects theschemas
attribute of the resource passed in the constructor and checks the default schemaurn
associated to the resource type is present in the list. If some of theurn
s part of theExtension
s 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 noschemas
in this resource or if some of theurn
s there are not known.
-
validateExtendedAttributes
public void validateExtendedAttributes() throws SCIMException
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 ofExtension
s passed in the constructor (everyExtensionField
has 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.
-
-