Abeona is the tool and library for creating and validating license files for Java applications. It is based on a set of properties they are characteristic for the customer and purchased application's configuration, and also on some cryptography.
The basic idea is very simple:
If you are new to the RSA cryptography, you should know that public / private keys pair are very large numbers bound together via mathematical theory about asymmetric cryptography. And in practice, all you need to know is that what you encode using private key, can be decoded with public key only. You can publish public key only, private key must stand secret.
Abeona uses 2048 bits keys. There is assumption computers will break this cipher in the year 2030. So you can protect your applications for next 20 years.
Note: This software is named Abeona after ancient Roman Goddess who protects children when they leave the parents' home.
Simply unzip downloaded file to appropriate directory (you must create such directory). You will get this structure:
ABEONA - this is the root directory when you unzip abeona_2010_3.jar - runnable JAR file license.txt - license agreement release.txt - list of the release changes DOC - documentation directory manual.html - Abeona manual, this is what you are reading IMAGES - directory with images for manual API - Javadoc directory EXAMPLES - Java examples for Abeona usage
Abeona creates its own working directory when first time running . This directory is located in <user-home> directory (on Windows systems C:\Documents and Settings\<user-name>) and is called abeona.
In this directory is stored Abeona product database and (if you purchased it) Abeona license file.
Abeona is protected by itself. The same system we offer to you is used to protect Abeona. So if you want use Abeona commercially, you must purchase valid license.
After you have payed Abeona, you will get Abeona license file to your email. Copy this file to Abeona working directory (see previous chapter) and start Abeona.
You should see you license number and name in the bottom left corner of application window.
Abeona GUI tool can be runned from command line with this command:
java -jar abeona_2010_2.jar
You must complete path to Java, if you have not set environment property (PATH=). You must complete path to JAR file if you are not in directory with abeona.jar.
This is the first screen you will see when running Abeona:
Note green text in left bottom corner. This is an information about your Abeona license. You can see two possible values here:
Table lists all products you have created.
There are buttons at bottom:
When you finishes with new application you will need create a new Product in Abeona system. Product is a simple record with a name (usually the name of your application) and with a template of your future license file.
Press Create product button to get this form:
Abeona generates new values of private and public key for created product when opening this form. It can take 3 - 15 seconds, so be patient, please.
In this form you can fill two fields:
Press Save button to save new product to database.
A new license you can generate from product list form.
There are three fields you can / must fill:
Press Use template button to fill License field from selected product template.
Press Save button to save new license to the file.
License file can be generated not only from GUI tool, but also from code. This capability is advantageous when you want generate license file on-line (e.g. via servlet).
All you need to generate license file from code is:
Your code is very simple, as you can see in next example. Note, properties and product ID in this example are fixed, you must use them as arguments in real life.
import java.io.IOException; import java.util.Properties; import eu.beesoft.abeona.Abeona; import eu.beesoft.abeona.LicenseException; import eu.beesoft.abeona.LicenseGenerator; import eu.beesoft.abeona.Product; import eu.beesoft.abeona.Database; /** * This example demonstrates how to create a new license file out of GUI tool - * just from code. * * @author Eugen Kocak */ public class BuildLicenseFromCode { public BuildLicenseFromCode (Abeona abeona) { // prepare your properties for generated license Properties properties = new Properties (); properties.setProperty ("customer", "Very Big Company"); properties.setProperty ("dbAccess", "enabled"); properties.setProperty ("netUpdate", "disabled"); properties.setProperty ("user.count", "25"); // get product database // it contains all your product (application) records Database db = abeona.getDatabase (); // get product by ID // here we obtain product #10 // you can see right product ID via GUI tool Product product = db.getProduct (10); // get license generator LicenseGenerator generator = abeona.getLicenseGenerator (); // sign and store license try { Properties signedProperties = generator.generate (properties, product); generator.storeLicense (signedProperties, product, "c:/myNew.license"); } catch (LicenseException le) { // TODO // thrown when cannot sign properties } catch (IOException ioe) { // TODO // thrown when cannot write properties to file } } public static void main (String[] arguments) { // you must always call main() method in Abeona // it requires as argument name of class to run // if it is null, GUI tool is invoked Abeona.main (new String[] { BuildLicenseFromCode.class.getName () }); // or you can run Abeona from command line this way: // java eu.beesoft.abeona.Abeona eu.beesoft.abeona.example.BuildLicenseFromCode } }
To validate license in your application you must:
If somebody changed license file, properties loading throws exception. And if license properties are not valid, each call to method getProperty (String) throws LicenseException too.
Here is an example:
import java.io.InputStream; import eu.beesoft.abeona.License; import eu.beesoft.abeona.LicenseException; /** * This example demonstrates how to use Abeona license system in real * application. * * @author Eugen Kocak */ public class StandaloneApplication { // public key generated by Abeona GUI tool // you must copy it to your application manually // in this example the default key (unlicensed Abeona) is used private final static String publicKey = "30820122300D06092A864886F70D01010105000382010F003082010A02820101008F933E73082743F49565B74FA6A5DC723EFACC97C6250830BCF2C3B6D440D8FE7001CC6C70E9625BA7A60048C6F9E284963BB618F43D9F91DEAC1BF2FF3A6E044E8E2F0D2007C19698EE210112A64054A2183DFC6DE0AC27244A3994BF142820CC9A67A01959427D52401BB2AFE6987D70496A30E4F505E867A69BD5324D76BA5327412BC83543EA29E7535EB2BDD7176774ED70891168C93723715BDA4F8F80BECEDEFE43300375B70285C33DE62B3E98E208D1CF89981DFC04EE7EE58FB301E4987E27072B4CA388A342C401D3B6D3DDCC6A590A7672525E3B40168021B1243CD6D72BB86610588ED7613684598DC9215F0681D93703BDE18E0D0EBFEC54810203010001"; /** * This piece of code shows how to load license file and how check / use its * properties. * * @throws LicenseException */ public static void main (String[] arguments) throws LicenseException { License license = new License (); // obtain input stream from license file // here you must use your own generated license file and path to it InputStream propertiesStream = StandaloneApplication.class .getResourceAsStream ("/eu/beesoft/abeona/example/example.license"); // load properties from file to instance of License class // LicenseException is thrown here if something goes wrong license.load (propertiesStream, publicKey); // get properties from license // each call to getProperty() throws LicenseException if license is // invalid String customerName = license.getProperty ("customer"); System.out.println ("Customer: " + customerName); String serialNumber = license.getProperty ("serial-number"); System.out.println ("Serial #: " + serialNumber); String isUpdateEnabled = license.getProperty ("update"); System.out.println ("Update: " + isUpdateEnabled); // here you can see the check for user system name String licenseUser = license.getProperty ("user"); System.out.println ("License user: " + licenseUser); String currentUser = License.getUserName (); System.out.println ("Current user: " + currentUser); if (!currentUser.equals (licenseUser)) { // do something } // here is similar check for MAC address String licenseMacAddress = license.getProperty ("macAddress"); System.out.println ("License MAC address: " + licenseMacAddress); String currentMacAddress = License.getMacAddress (); System.out.println ("Current MAC address: " + currentMacAddress); if (!currentMacAddress.equals (licenseMacAddress)) { // do something } } }
Of course, you must abeona.jar file ship with your application.
Abeona classes have capability to work as license server.
Class eu.beesoft.abeona.License has implemented method
void load (String host, String port, String applicationName, String publicKey)
to load properties from license server. Arguments host and port are connection strings to server (HTTP is used), applicationName is your own identifier for running application (the same name must be used on client and server side). Argument publicKey is public key of suitable product as in previous example. But this argument can also be null and in such case are properties just loaded from server but not validated.
Class eu.beesoft.abeona.LicenseServer is abstract class you can use to build your own license server. There is just one method you need serve:
Properties getProperties (String application, String user);
Argument application is application name as received from client. Argument user is system name of current client user and is produced by License class.
To build license server you need create class derived from LicenseServer and write method getProperties(). What you will send to client or how you will check user request is in your hands only.