Previous Topic: Plug-In ClassesNext Topic: Converters


Validators

A validator is a Java class that verifies the validity of either individual values, attributes, or an entire object class. CA IAM CS uses validators to help ensure that data values meet specific requirements before being passed to or from the endpoint system for processing. Validators also support localized error messages (using Sun internationalization support built into the JDK), which converters do not.

For example, if the legitimate values for a field are X, Y, and Z, then a validator checks modification requests to verify that values are always in the accepted set. The built-in com.ca.jcs.validator.meta.EnumValueValidator already does this verification where the permitted values are specified in an enum definition the data model metadata.

Where possible, using plug-in validators or converters increases opportunities for code reuse across connectors.

You can find several bundled validators to handle common scenarios in the packages com.ca.jcs.validator.attr and com.ca.jcs.validator.meta. These packages contain plug-ins with global scope and are therefore registered using the file conf/server_jcs.xml.

The SDK connector registers an example com.ca.jcs.sdk.validator.NoCommaAttributeValidator, including support for localizing its messages using the messageResourceBundle field in conf/connector.xml. This enables file access for the connector's files validator.properties (English) and validator_fr.properties (French), depending on the locale of your Java Virtual Machine.

Note: When testing, you can temporarily change jcs.bat and jcs.sh and try different locales using command lines like the following to run CA IAM CS:

java -Duser.language=fr ...

Note: For more information about Locale objects, see Understanding Locale in the Java Platform at http://java.sun.com/.

Typically, you run validators only on information received from the client. However, if you also want to enable validation on LDAP query responses, you can set the validateFromConnector attribute on your ConnectorConfig JavaBean in the connector.xml file.

Note: The package com.ca.jcs.validator contains validators that handle several common scenarios such as checking that attribute values conform to a maximum length or fall within a prescribed set of enum alternatives.