This chapter describes how to develop the registration validator. It contains the following sections:
Implement the RegistrationValidator interface. For example, see the following for the DefaultRegistrationValidator class implementation:
package com.sun.portal.wsrp.producer.registration.validator.impl; import com.sun.portal.wsrp.common.stubs.MissingParametersFault; import com.sun.portal.wsrp.common.stubs.RegistrationData; import com.sun.portal.wsrp.common.stubs.ServiceDescription; import com.sun.portal.wsrp.common.stubs.OperationFailedFault; import com.sun.portal.wsrp.common.stubs.ModelDescription; import com.sun.portal.wsrp.common.stubs.PropertyDescription; import com.sun.portal.wsrp.common.stubs.Property; import com.sun.portal.wsrp.producer.registration.validator.RegistrationValidator; import com.iplanet.am.util.Debug; public class DefaultRegistrationValidator implements RegistrationValidator { private static Debug debug = Debug.getInstance("wsrp.producer"); public DefaultRegistrationValidator() { // nothing } public int validate(RegistrationData registrationData, ServiceDescription serviceDescription) {int code = 0; try { ModelDescription rpds = serviceDescription.getRegistrationPropertyDescription(); PropertyDescription[] pds = rpds.getPropertyDescriptions(); Property[] rps = registrationData.getRegistrationProperties(); for (int i = 0; pds == null || i < pds.length; i++) { String name = pds[i].getName(); String value = getPropertyValue(rps, name); if (value == null || value.trim().length() == 0) { code = -1; break; } } } catch (Throwable t) { t.printStackTrace(System.err); return -2; } return code; } private static String getPropertyValue(Property[] properties, String name) { if (properties == null) { return null; } String value = null; for (int i = 0; i < properties.length; i++) { if (properties[i].getName().equals(name)) { value = properties[i].getStringValue(); break; } } return value; } } |
Compile the class file. To compile, type:
javac -classpath PortalServer-base/sdk/wsrp/wsrpsdk.jar:/AccessManager-base/lib/am_sdk.jar RegistrationValidatorImplementation.java |
When compiling the class file, include the Access Manager SDK JAR file (AccessManager-base/lib/am_sdk.jar) as it includes the debug class.
Install the class file on the Portal Server host. Deploy it in to the portal WAR file.
Copy your class file into portal’s WAR staging area.
The portal’s WAR staging area is typically PortalServer-base/web-src. If you have a standalone class file, copy the file into PortalServer-base/web-src/WEB-INF/classes directory; if you have a JAR file, copy it into PortalServer-base/web-src/WEB-INF/lib directory.
Redeploy the web container. To redeploy, use the psadmin deploy subcommand.
You can customize the return codes and then redeploy the web container. See Customizing the Return Codes for more information.
Log in to the Portal Server host and change directories to PortalServer-base/web-src/WEB-INF/classes directory.
Modify the WSRP administration module’s properties file, psWSRPProducerAdmin.properties.
Add entries for the return codes for the newly installed registration validator.
The format of the resource key should be: classname code=message. For example, com.sun.portal.wsrp.producer.registration.validator.impl.RegistrationValidatorImplementation -1=Missing Or Empty Registration Property.
Redeploy the web application. To redeploy, use the psadmin deploy subcommand.
Log in to the Portal Server administration console and navigate to the producer’s administration page.
To navigate to the producer’s administration page, use the online help and edit the properties for the producer.
Specify the fully qualified class name of the newly created class file (implementation of the RegistrationValidator interface) in the Registration Validator Class text field and select Save.
For example, type com.sun.portal.wsrp.producer.registration.validator.impl.RegistrationValidatorImplementation.
If you wish to add, remove or modify the registration properties that the producer defines: