Implement Custom Validation Rules with Java
A Java-based validation rule must implement the relevant interface, depending on whether the rule is used for task-level validation or directory-level validation.
cim1265
A Java-based validation rule must implement the relevant interface, depending on whether the rule is used for task-level validation or directory-level validation.
At validation time,
Identity Manager
calls validate() and passes the value to be validated.This page contains the following topics:
Java Interface for Task-Level Validation
The definition of the Java interface for task-level validation is as follows:
- Syntaxpublic interface TaskValidator { public class StringRef { public String reference = new String(); public String toString(){return reference;} public boolean validate( BLTHContext ctx, String attrValue, StringRef updatedValue, StringRef errorMessage ) throws AttributeValidationException; }
- Parameters
- ctxInput parameterSpecifies an object that contains methods for retrieving information in the current task session.
- attrValueInput parameterSpecifies the value of the attribute being validated.
- updatedValueOutput parameterProvides an optional transformation value that replaces the user-supplied value being validated. When no transformation is necessary, pass back null.
- errorMessageOutput ParameterIf validation fails, it displays a message to the user.
- CommentsFor more information about Java validation rules and on managed objects, see theIdentity ManagerJavadoc.
- Returns
- True -- the implementation considers the value inattributeValueto be valid, or it passes back a transformed value inchangedValue.
- False -- the implementation considersattributeValueto be invalid.
- ThrowsAttributeValidationException
Java Interface for Directory-Level Validation
The definition of the Java interface for directory-level validation is as follows:
- Syntaxpublic interface IAttributeValidator { public class StringRef { public String reference = new String(); public String toString(){return reference;} public boolean validate( Object attributeValue, StringRef changedValue, StringRef errorMessage ) throws AttributeValidationException; }
- Parameters
- attributeValueInput parameterSpecifies the value of the attribute being validated.
- changedValueOutput parameterProvides an optional transformation value that replaces the user-supplied value being validated. When no transformation is necessary, pass back null.
- errorMessageOutput parameterIf validation fails, it displays a message to the user.
- CommentsIf the validation operation requires managed objects from the directory, use AttributeValidator. This abstract class implements the IAttributeValidator interface, and includes a method for retrieving the managed object providers.
- Returns
- True -- the implementation considers the value inattributeValueto be valid, or it passes back a transformed value inchangedValue.
- False -- the implementation considersattributeValueto be invalid.
- ThrowsAttributeValidationException.