Previous Contents DocHome Index Next |
iPlanet Trustbase Transaction Manager 2.2.1 Developer Guide |
Chapter 9 Ping Example
The following sections use the Ping DTD as defined in the Identrus messaging specification to walk through the steps in the development cycle as described in the previous chapter. Developing a service prior to deploying it involves a number of steps.
Create your DTD definitions that specify the syntactic structure of the messages you wish to send round the system.
Use Classgen com.iplanet.trustbase.app.classgen.ClassGen to generate your java classes from your DTD definitions.
Write the Java code for the service using the Identrus API that assists the Identrus processing and validating of messages, certificates, keys and digital signatures.
Use the JDK JAR tool to build the final iPlanet Trustbase Transaction Manager service jar file.
Deploy the service within iPlanet Trustbase Transaction Manager by selecting the relevant configuration options as described below in this guide.
Finally, once it has been deployed within iPlanet Trustbase Transaction Manager itself you can run your service.
This example uses the 'Ping' DTD defined in the Identrus Messaging specification and included below for completeness. Thus, create your DTD definitions which can be found in ping.dtd. (See IT-TCMPD, the Identrus TC Messaging Specification for the structure and definition of ping.dtd)
Prepare to execute the ClassGen tool by completing the following steps:These link to other dtd files that are supplied with iPlanet Trustbase Transaction Manager and are listed below:
XMLDSIG.dtd
corenetworkinfrastucture.dtd
Foundation.dtd
Note All dtd's can be found in <install-dir>/Trustbase/TTM/current/apidocs.
Change directory to ../Trustbase/TTM/Scripts
Set up the classpath ready for the ClassGen tool to be executed. This is done by sourcing the setcp script. E.g. ". ./setcp" in the standard shell.
Make a new sub-directory called ping and make this the current directory
Copy ping.dtd and each of the 3 core Identrus DTD's to the new directory. It is essential that the names of the DTD files are correct, they are case sensitive and their exact names can be found by looking inside the DTD files. The last attribute of an <!ENTITY ....> tag defines the local file name for the included DTD.
Establish which options must be passed to the ClassGen tool, Table 9-1 shows each of the options for this example.
Table 9-1    Classgen Options
This results in the following command being issued:
The result of executing this command is the following:
Many warnings on the screen. These warnings state that classes have not been generated for certain elements in the DTD's referenced from the ping.dtd. This is because these classes already exist on the classpath of iPlanet Trustbase Transaction Manager and therefore do not need to be regenerated.
With the JAR file and the stub service generated, you can now move to the next stage of the development of a service.A file called ping.jar in the current directory. This contains the compiled message classes for the ping DTD.
A sub-directory called src that contains the source code of all of the generated class files.
A file called PingService.java in the current directory. This is the stub Identrus Service that needs to be updated with message processing code in the next stage.
API
Before writing your Java code you'll need to know some of the core API that is supplied with iPlanet Trustbase Transaction Manager for handling Identrus Messages:
com.iplanet.trustbase.identrus This package allows access to Identrus message Specification
com.iplanet.trustbase.identrus.message This package provides the necessary routines to allow Identrus message processing
com.iplanet.trustbase.identrus.security This package processes certificates and keys
com.iplanet.trustbase.util.tree Searches tree
com.iplanet.trustbase.xml.dsig Generates and validates XML Digital signatures, this package is not required if the only signatures on the messages are the mandatory level 1 signatures. These mandatory signatures are checked/generated automatically by iPlanet Trustbase Transaction Manager.
uk.co.jcp.tbase.config This package interfaces with configuration objects
PingService Source Code
PingService.java - the generated service stub is an implementation of the abstract IdentrusService in which the ProcessIdentrusMessage method parameter is the message received by the TTM platform.By the time the message arrives at this ProcessIdentrusMessage method, it has already passed mandatory signature validation checks and been raw logged.
The method must create a response message to the incoming request. Using the supplied Identrus API's this is simple.
Having written this simple service it may be compiled ready to be built into a Service JAR.
Creating the Identrus Service JAR
The final step before deploying the service into iPlanet Trustbase Transaction Manager is to create the consolidated JAR file that contains all of the generated classes as well as the PingService class that has been developed by hand.Building the iPlanet Trustbase Transaction Manager service jar is a simple matter of the following steps:
Using the standard JDK 'jar' tool, unpack the generated jar file into a directory.
mkdir DumpDirectory
cd DumpDirectory
jar -xvf ../ping.jar
cd ..Beneath the 'DumpDirectory' copy in all of the classes which are required for the processing of the message. Ensure that the correct package structure is maintained for all these classes. n.b. Remember that the service stub class must not have been re-packaged since the class generation created it.
Using the standard JDK 'jar' tool, repack the archive
jar -cvf ping.jar -C DumpDirectory DumpDirectory/*
Deploying ping.jar within iPlanet Trustbase Transaction Manager
Place ping.jar in the deploy directory. ...../Trustbase/TTM/current/deploy
Logon to iPlanet Trustbase Transaction Manager as Administrator
Deploy PingService within iPlanet Trustbase Transaction Manager. Select <Services> followed by <Deployment>.
Since Ping.jar has been placed in the deploy directory automatically by the builder, iPlanet Trustbase Transaction Manager picks up all the relevant information and places this in the screen headed "Available services" as illustrated below.
Figure 9-1    Deploying PingService within iPlanet Trustbase Transaction Manager
Services require registration. This is done automatically when the jar file is built from the builder tool. PingService can in fact be seen from the Configuration Console by selecting <Services> <Registry Configuration> as illustrated below:
Figure 9-2    Service Registry Configuration
Services may also require authorisation. Select <Authorisation><Add Service>. The service itself will need to be assigned a role, as illustrated below:
Figure 9-3    Assigning a role to a service
Note If no role is available you may have to define a role. Consult the Configuration and Installation Guide for more details about this.
Previous Contents DocHome Index Next
Copyright © 2001 Sun Microsystems, Inc. Some preexisting portions Copyright © 2001 Netscape Communications Corp. All rights reserved.
Last Updated April 19, 2001