The Source for Java Technology Collaboration


Getting Started With the SPML Gateway for JDBC (using a servlet) Solution

This solution shows how you can use the SPML Gateway to provision users in any application that uses a database for managing users. The database must be accessible through a JDBC driver which must be supplied to this solution.

This solution is implemented as a Servlet and requires a JDBC Resource registered in the application server. The JNDI name of the resource that is currently being used is "jdbc/sample". This name can be changed in the source code to any JNDI resource that is available in your application server. This solution is intended to be a starting point to SPMLv2 enable your database based application. The SQL statements within the servlet source code can be modified to conform to the table(s) that house your users for your application. The sample table structure that is being used consists of the following fields:

users
psoid
name
password
passwordstatus
state

The psoID column holds the unique identifier for the user. Name is the users account name. Password is the users password. Passwordstatus is either expired or valid. This is used to manage the state of the password. If the password has been expired then this field is set to 'expired' otherwise it is set to 'valid'. State stores the state of the account. The account can be active or disabled.

The following SPML operations are supported:

Operation Description
listTargets Lists the targets that a provider makes available for provisioning.
add Creates a new object on a target.
lookup Obtains the XML that represents an object on a target.
modify Changes an object on a target.
delete Removes an object from a target.
suspend Disables an object.
resume Reenables an object.
active Determines whether an object has been suspended.
setPassword Change the password to a new value.
expirePassword Marks the users password state to expired.
resetPassword Reset the password to a new generated one.
validatePassword Checks to see if the submitted password is the correct one.

Architecture of the JDBC Solution

This gateway is implemented in a servlet. The messages will arrive via http to the url of 'http://localhost:8080/spmlv2/Provisioner'. The request will be parsed using XPath and DOM to pull out the relevant information and then the database will be queried and updated accordingly.

Installing the JDBC Solution

This procedure assumes that you have installed OpenESB or NetBeans 6.1

To Install the JDBC Solution

  1. Download the zip file that contains the solution.
  2. Unzip the contents to the directory that contains the NetBeans projects (for example, C:\Documents and Settings\user\My Documents\NetBeansProjects).
  3. Launch the NetBeans IDE.
  4. Choose File > Open Project... from the main menu.
  5. Select the projects for the solution and click Open Project.

Building and Deploying the JDBC Solution

To deploy the solution just Right-click on the SPMLv2forJDBC? project and select the "Undeploy and Deploy" as can be seen below:

Testing the JDBC Solution

You can find here (this netBeans project is located here) a simple swing based tester. Nothing special. Just something that can help test out your SPMLv2 service. It creates an XML template for you to fill out. Invokes the service. And then shows you the raw response. Again nothing special, but something that can show you whats going on in your SPMLv2 Service.

Just download the zip file, expand it into a directory and open the SPMLExplorer.jar file (double clicking on it should do the trick). If you have your .jar extension files set to run java -jar it should start up. If not you can always run from the command line "java -jar SPMLExplorer.jar".

The application first requires you to set up the location of the target. This is done by "File --> Open Target.." from the main menu. This will open up the below dialog box. Where you enter in the URL for the SPMLv2 Service. The default location of the servlet on your local machine will be "http://localhost:8080/spmlv2/Provisioner". You can ignore the username and password for now. This will be something for a future enhancement.

Now that you have the target set. Make sure that it is selected and then pick the operation you want to call by selecting it from the "Call --> listTargets" for example from the main menu. This will insert the xml template into the upper window. You can now change the XML content to match your scenario and then finally you can click on the Execute Button to run the command to see the results in the bottom window.

JDBC Solution Overview

In the zip file you will find one project.

The SPMLv2forJDBC project contains a group of files that implement the supported SPML operations.

The following screen capture shows the SPMLv2forJDBC project in the NetBeans IDE.

There are four files that are interesting. The two java files Provisioner.java and NamespaceContectImpl?.java. And the two deployment descriptors web.xml and sun-web.xml.

Changing the location of the database JNDI Resource

The JDBC resource is currently mapped to jdbc/sample. This is defined in the web.xml file as can be seen below.

And in the sun-web.xml file as can be seen here.

This can be changed

Modifying the JDBC Solution

The logic for what is done for each of the SPMLv2 operations is contained in the Provisioner.java file. You can change the database JNDI Resource name. You can change the schema of the database table...

Topic GettingStartedJDBC . { Edit | Ref-By | Printable | Diffs r1 | More }
 XML java.net RSS

Revision r1 - 15 Aug 2008 - 01:33:29 - Main.jerrywaldorf
Parents: WebHome > Keychain