Sun Java logo     Previous      Contents      Index      Next     

Sun logo
Sun Java System Portal Server 6 2004Q2 Developer's Guide 

Chapter 15
Defining Custom Registration Validators

This chapter describes how to develop the registration validator. It contains the following sections:

Implementing the RegistrationValidator Interface

  1. Implement the RegistrationValidator interface. For example, see Code Example 15-1 for the DefaultRegistrationValidator class implementation:
  2. Code Example 15-1  DefaultRegistrationValidator Class File  

    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;


    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;




            } catch (Throwable t) {


                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();




        return value;



  3. Compile the class file. To compile, type:
  4. javac -classpath portal-server-install-root/SUNWps/sdk/wsrp/wsrpsdk.jar:/portal-server-install-root/SUNWam/ lib/am_sdk.jar

    When compiling the class file, include the Identity Server SDK JAR file (identity-server-install-root/SUNWam/lib/am_sdk.jar) as it includes the debug class.

Installing the Class File

Install the class file on the Portal Server host. Deploy it in to the portal war file.

To install via the web container war file:

  1. Copy your class file into portal’s WAR staging area.
  2. The portal’s WAR staging area is typically /opt/SUNWps/web-src. If you have a standalone class file, copy the file into portal-server-install-root/SUNWps/web-src/WEB-INF/classes directory; if you have a JAR file, copy it into portal-server-install-root/SUNWps/web-src/WEB-INF/lib directory.

  3. Redeploy the web container. To redeploy, type portal-server-install-root/SUNWps/bin/deploy redeploy -deploy_admin_password password.
  4. You can customize the return codes and then redeploy the web container. See For example, type com.sun.portal.wsrp.producer.registration.validator.impl.RegistrationValidatorImplementation. for more information.

Customizing the Return Codes

  1. Log in to the Portal Server host and change directories to portal-server-install-root/SUNWps/web-src/WEB-INF/classes directory.
  2. Modify the WSRP administration module’s properties file,
  3. Add entries for the return codes for the newly installed registration validator.
  4. 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.

  5. Redeploy the web application. To redeploy, use the portal-server-install-root/SUNWps/bin/deploy redeploy -deploy_admin_password password command.

Configuring the Producer’s Registration Validator

To administer the producer:

  1. Log in to the administration console and navigate to the producer’s administration page.
  2. To navigate to the producer’s administration page, you must select Services from the View pull-down menu —> WSRP Producers —> Edit Properties for the producer.

  3. 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.
  4. For example, type com.sun.portal.wsrp.producer.registration.validator.impl.RegistrationValidatorImplementation.

  5. If you wish to add, remove or modify the registration properties that the producer defines:
    1. Select the Registration Properties tab in the administration console.
    2. Edit the properties or select New to add a new property.
    3. Select OK.

Previous      Contents      Index      Next     

Copyright 2004 Sun Microsystems, Inc. All rights reserved.