Call a Java class from a LotusScript agent

Background

Our client need to have user profiles opened in a Domino web form. The users were already authenticating in Domino from their LDAP directory. Their usernames contain a unique identifier for them so we could look them up in their native LDAP directory and pull all their bio info (name/address/phone, etc) and they wouldn't be required to enter it manually. This was especially nice given the fact that they didn't have Domino person documents and were updating their bio info from another system.
The LDAP query was done using a dll we got from the Notes.net sandbox entitled "LotusScript Directory Service".

One nice thing about our original agent was that we wrapped all the gathering of the LDAP values into a LotusScript class. By using Object Oriented (OO) capabilities in our class, we could easily loop through the Domino fields looking for matches in the LDAP attributes. We told our client to name the fields the same in both to avoid having to do a mapping table. Plus, it lets them add new fields easily without any additional changes to the code.


The limitation

Recently our client required the LDAP calls to be done securely (SSL). On investigation, we realized that the .dll file we were using didn't include the capacity to perform queries over SSL (port 636).


LS2J to the rescue

LS2J is an interface built into LotusScript since version 6.x that allows developers to call a Java class and use the methods and properties of that class from within a LotusScript agent. You can find out about it by looking for LS2J in the designer help database.

To the drawing board

First thing we had to do was add the trusted certificate to the cacerts file. This is a keytool call on the Java side of things on the server. I won't go into those details here as this article is focusing on the core LS2J feature.

Also, we used Notes 7/Domino 7 which included more recent Java files necessary to run this code. You can install files to Notes/Domino 6 but they are included in 7 so it's easier to implement. We had to use JNDI to make the LDAP calls.

The second thing we had to do was rewrite our original class.

The new Java class (stored in a script library) did the following:

Made a call to the LDAP directory using login info stored in a Notes document (reader restricted)
Grabbed the correct LDAP entry using the unique key of this user
Looped through the entry grabbing all attributes and values - inserting into a Hashtable


.....


Our LotusScript agent - making the call to the Java class

The class is "LDAPValuesJava" and the connection function is called "LDAPConnect". The other important function is called "GetValue". See important pieces of the code in red below. Not that this is not the entire agent code. Just enough to get the point across.



Yawn....So what?

This opens up a lot of possibilities, especially for a more seasoned LotusScript developer and less seasoned Java developer, to the capabilities to put Java classes that do things like (a) make LDAP calls, (b) zip files in the back-end on the server, (c) make thumbnails of images, etc. but with the original LotusScript agent as the wrapper. Some of these ideas are out on the web if you google LS2J.

It allows a developer to pass the results of the work of the Java class back into LotusScript.

Can we have your source code?

Yes! We spent a good deal of time getting this to work for us. Now that it's done, we were able to trim it down and name it appropriately and make it easy to understand with comments, etc. But if you want to save some time, we are offering the source code and a demonstration video with sound (in .wmv format) in a package.

Buy it now

We will send you all source code and a step by step demonstration. You can add it to your application and add more features if you want but at least you will have a sound starting point of production code.

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by LavaTech, Inc.

Domino Administration