Русский | English
About company | News | Products | Solutions | Services | Support | For developers | Articles | Sitemap
Use of Java classes in Lotus Script code
For developers
Forum

USE OF JAVA CLASSES IN LOTUS SCRIPT CODE

Author: Rafael Osipov
Introduction

The main purpose of this article is to describe a mechanism to use Java classes within LotusScript code. To prepare this article I used IBM Lotus Notes R7 software.

You may create Lotus Notes applications with use of LotusScript and Java code. IBM Lotus Notes Client 7.0 supports JDK 1.4.2. Both Java and LotusScript have advantages and disadvantages. And a [professional] developer has to use these tools in combination to multiply advantages and minimize possible disadvantages.

Lotus Script to Java technology (LS2J) allows to make calls to Java code whitin LotusScript code.

At the first glance this opportunity is superfluous. After all we have a way to link heterogeneous code parts via profile documents and/or environment variables.

But it is not too convenient way. In this article we consider an example application, which uses Java classes to support encryption and signing functionality. In LotusScript there is no such functionality present. And it is not too easy to implement similar functionality with “pure” LotusScript.

There is an additional point. Compiled LotusScript code and Java code are stored in different way. Java classes are packaged into jar-files and attached to agents or script library elements. LotusScript object code stored as byte array into special design element fields.

If there is a necessity, it is possible to detach jar files from script libraries and/or agents, decompile them and analyze. Lotus Notes does not make java code optimization nor obfuscation.

And it is possible to decompile java class files and gain access to all information regarding class names, methods and fields. It is possible to create new design elements, place there decompiled and updated code, and afterwards place modified design elements instead of original code to change application behavior.

As far as I know there is no existing LotusScript object code decompilers.

Due to this reason I suppose to use LS2J interface when you need to use Java classes, and you plan to protect application logic against reverse-engineering.

Use of signing/verifying mechanisms in Lotus Notes applications

Into this article I describe a Lotus Notes application which creates and verifies digital signature.

To catch events when digital signature does not conform to the document contents I use Java classes instead of standard Notes functionality. Notes just allows to *see* in status bar an error message if a document signature or content is corrupted. It is acceptable in some cases when a user just needs to get a visual signal that document contents cannot be trusted. But in cases, when digital signature violation has to have an effect on application behavior this does not help.

This mechanism implemented on Java.

Digital signature processing works according to the following rules:

For a text block we generate unique digital sequence (digest). And after that we encrypt this digest with private RSA key.

To verify text and signature we do the following:

We generate the digest for text to be verified. And we are trying to decrypt encrypted digest (signature) and compare it with just generated digest. If decrypted and just generated digests are the same, then text and signature verified ok. Otherwise document contents cannot be trusted.

Element type
Element name
Description
Form
License
Exemplar form to show contents of document to be signed and/or verified.
View
($All)
Shows list of database documents and contains buttons to sign and verify document contents.
View
(License)
Shows document to be signed and/or verified.
Agent
(Sign)
Signs the document.
Script Library
SignatureProcessing.lib
Contains code to support signature verifying.
Main function: isLicenseCorrect

Into script library SignatureProcessing.lib and agent aa_Sign there is a function (method) with name: getDocumentText (). It is responsible for composing text block to be signed/verified. If you wish to change agent code you have to change this function in the script library too.

If you plan to use this sample code in a real application it is strongly recommended to place all code from SignatureProcessing.lib into another common use library. It is necessary to mix signature verifying code with other common code.

If you leave this library alone into the real application the following situation may arise. A hacker may create a new library with the same name, and force verifying function to return OK for ever and for any condition. And afterwards he just replaced your library with the modified code.

Agent code (for aa_Sign agent) is written on Java. If you wish you may rewrite it on LotusScript with use of LS2J technology.

The key factor of security into sample application is that hacker does not know exact mechanism of text block composition. Otherwise he may create code to generate new signature and replace fields into signed document.

To strengthen this security mechanism you may include public key into LotusScript code that verifies the digital signature.

Description of sample LS2J application

Imagine that you have created a complex and expensive Lotus Notes application and you’re going to sell it.

Your application consists of a set of *.nsf files with excluded source code (hidden design).

And what if a customer will give a copy of your application to someone else?

Yes, you may use serial numbers, which have to be specified during installation process. But serial numbers also can be copied.

To protect your application against unauthorized use, I recommend to use the following approach:

Along with the application we provide the customer with signed license notes document. Into license document there is digitally signed information about customer’s company name, quantity of workspaces, etc.

When a user works with the system, the application checks license document integrity and checks conditions to allow or prohibit a certain action.

Company title and other information from the license document has to appear in the header of every printed documents. It would stop an other company to use this application with stolen/copied license document.

I have to say that the goal is not to create an unbreakable protection. The protection is pretty good if the breaking process takes more money than buying a valid license.

You may download example database with functionality for creating and verifying digital signature.

When you’ve opened downloaded example database you see a view with one document and two action buttons. "Sign" and "Verify".

To sign the document just press “Sign” button. And to verify signature – press “Verify”.


Тел.: +7 (495) 918-3314, +7 (495) 918-3111. Факс: +7 (495) 918-3111. E-mail: info@ronix.ru, support@ronix.ru
(c) 1997-2008 Ronix Systems. All rights reserved.