Skip to content

Starschema License Manager 4 Java - an easy-to-use, simple license file generator and validator engine

License

Notifications You must be signed in to change notification settings

chrishein/slm4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 test1.pub (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 test1.pub -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 test1.pub -private test1.pkf -sign output2.txt

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

$ java -jar SignatureCreator.jar verify -sign output1.txt -public test1.pub
License is valid
$ java -jar SignatureCreator.jar verify -sign output2.txt -public test1.pub
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 test1.pub
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
ExpirationDate=20090630
Version=Full
----- END LICENSE -----
----- BEGIN SIGNATURE -----
MCwCFCKRoTnYFdE7JJzH
W2XQddSq9wqCR43hRQ+J
BZV5FS+ZU5j90JAZFUA2
WQ==
----- END SIGNATURE -----

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

About

Starschema License Manager 4 Java - an easy-to-use, simple license file generator and validator engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published