Java (Maven) License Key Encoder and Validator for the weweave Commerce platform
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
pom.xml

README.md

weweave Commerce License Key Encoder and Validator for Java

This Maven artifact allows for encoding and validating license keys and building domain lists for the weweave Commerce platform.

To use this library in your Java project, add the following Maven dependency to your pom.xml:

<dependency>
    <groupId>net.weweave.commerce</groupId>
    <artifactId>key</artifactId>
    <version>1.0.0</version>
</dependency>

Requirements

This library requires Java 1.8 or later.

Private and public keys for signing and checking the signature of a provided license key requires an RSA public-private-key-pair in PEM format. Check out the documentation for information on how to create one.

Checking a license key

To check the validity of a provided license key, use a code block like this:

String in = "<License Key goes here>";
File publicKey = new File("rsa-public-key.pem");
LicenseKeyEncoder key = LicenseKeyEncoder.factory(in, publicKey);
 
System.out.println("Product: " + key.getProduct());
System.out.println("Subject (i.e. Domain Regex): " + key.getSubject());
System.out.println("Licensee: " + key.getOwner());
System.out.println("License Type: " + key.getType());
System.out.println("Issue Date: " + key.getIssueDate());
System.out.println("Expiry Date: " + key.getExpiryDate());

Encoding a license key

DomainList dl = new DomainList();
dl.addDomain("localhost", false, false);
dl.addDomain("local", false, false);
dl.addDomain("weweave.net");
dl.addDomain("microsoft.de");
String subject = dl.getRegEx();
 
LicenseKeyEncoder key = new LicenseKeyEncoder();
key.setProduct("ProductIdentifier");
key.setOwner("Name of licensee");
key.setSubject(subject);
key.setIssueDate(new Date());
Calendar cal = new GregorianCalendar();
cal.add(Calendar.MONTH, 1);
key.setExpiryDate(cal.getTime());
key.setType(LicenseKeyEncoder.TYPE_TRIAL);
 
File privateKey = new File("rsa-private-key.pem");
String keyString = key.getLicenseString(privateKey);

License types

weweave Commerce supports three types of license keys:

  • trial: A trial/evaluation license with limited functionality.
  • limited: A full-features license which is limited in time.
  • lifetime: A lifetime license which will never expire.

Advanced features

You can use the online verification feature to perform a live-validation of a license key via your servers using the UUID which can be included in the license keys optionally:

System.out.println("Online verification: " + key.getOnlineVerification());
System.out.println("UUID: " + key.getUuid());

Documentation

Please read the documentation and the JavaDoc for more information.