Starschema License Manager 4 Java - an easy-to-use, simple license file generator and validator engine
Latest commit 9187d36 Jul 20, 2009 Gabor Toth Set JDK to 1.3 from 1.6
Failed to load latest commit information.
dist Initial release on github Jul 7, 2009
doc Add possibilities to access signed data Jul 14, 2009
build.xml Set JDK to 1.3 from 1.6 Jul 20, 2009 Initial release on github Jul 7, 2009


Starschema License Manager for java (slm4j)

Slm4j project aimed to provide an easy-to-use, easy-to-implement license manager system for java projects.

Basic functionality

The project includes a command line tool to generate private and public keys for cryptographical signing, and a runtime class (or jar module) to validate the generated keys.

The signed data is an ASCII armored file, which could store date or time limitations, functionality restrictions or any user specified strings. The embedded license file validator ensures that file is not modified by using DSA algorythm.

Command line usage

The following command signs input1.txt file and writes the result to output1.txt. If (public key file) and test1.pkf (private key file) do not exists, then these files are automatically generated.

$ java -jar SignatureCreator.jar  sign -license input1.txt -public -private test1.pkf -sign output1.txt

After the initial key generation, the generated key files are used for futher sign actions.

$ java -jar SignatureCreator.jar  sign -license input2.txt -public -private test1.pkf -sign output2.txt

To verify the generated keys use the "verify" action:

$ java -jar SignatureCreator.jar verify -sign output1.txt -public
License is valid
$ java -jar SignatureCreator.jar verify -sign output2.txt -public
License is valid

To check what happens if we modify the generated license file use our favourite editor and try it:

$ vim output2.txt
$ java -jar SignatureCreator.jar verify -sign output2.txt -public
License is not valid

Usage from java programs

To validate a user supplied license file in your application, you must include your public key file in the binary distribution (eg. in a hardcoded static private string in your license handler class) and import SignatureValidator.jar file. To check the input license file, issue:

 private static final String PUBLIC_KEY = "...";

 try {
   SignatureValidator validator = new SignatureValidator();

   if ( validator.verifyLicenseWithString( PUBLIC_KEY, fileToValidate ) )
     System.out.println("License is valid");
     System.out.println("Registred to: " + validator.getLicenseOptions().get("RegistredTo") );                 
   } else {
     System.out.println("License is not valid");
 } catch (SlmException ex) {
   System.out.println("Can not load license information: " + ex.getMessage() );

For more information please refer to included javadocs.

Example license file

The following file was generated by slm4j:

----- BEGIN LICENSE -----
RegistredTo=John Smith
----- END LICENSE -----
----- END SIGNATURE -----

Any changes in license data will cause an invalid license exception.