Implement the RegistrationValidator interface. For example, see the following for the DefaultRegistrationValidator class implementation:
/*
* CDDL HEADER START
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* http://www.sun.com/cddl/cddl.html and legal/CDDLv1.0.txt
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
* CDDL HEADER END
*/
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 {
public DefaultRegistrationValidator() {
// nothing
}
/**
* This method returns three possible codes.
* 0=succes
* -1=Missing Registration Property
* -2=Unknown failure
*/
public int validate(RegistrationData registrationData, ServiceDescription serviceDescription) {
int code = 0;
try {
ModelDescription rpds = serviceDescription.getRegistrationPropertyDescription();
PropertyDescription[] pds = (PropertyDescription[])rpds.getPropertyDescriptions().
toArray(new PropertyDescription[0]);
Property[] rps = (Property [])registrationData.getRegistrationProperties().
toArray(new Property[0]);
//
// for every registration property description in the
// service description, make sure that the
// registration properties contains a like-named
// property and that the like-named property's value
// is non-null and not empty
//
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.