Coder Social home page Coder Social logo

slm4j's Introduction

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.

slm4j's People

Contributors

tfoldi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.