Abeona 2012.1 API

eu.beesoft.abeona
Class Abeona

java.lang.Object
  extended by eu.beesoft.abeona.Abeona

public final class Abeona
extends java.lang.Object

Main class of Abeona signature system.

Loads Abeona license and checks it. Loads or creates database of Product instances. Runs GUI tool for user access.

This class also contains a few utility functions for work with streams and public / private keys.


Field Summary
static java.lang.String UNLICENSED
          This constant is returned by method getSerial() if Abeona is running in unlicensed mode.
 
Method Summary
static java.security.interfaces.RSAPrivateKey buildPrivateKey(java.lang.String data)
          Builds public key (as instance of RSAPrivateKey) from given hexadecimal String.
static java.security.interfaces.RSAPublicKey buildPublicKey(java.lang.String data)
          Builds public key (as instance of RSAPublicKey) from given hexadecimal String.
static byte[] computeSignature(byte[] data)
          Computes MD5 hash signature for given data.
static byte[] decrypt(byte[] data, java.security.Key key)
          Decrypts given data with given key.
static byte[] encrypt(byte[] data, java.security.Key key)
          Encrypts given data with given key.
 void generateLicense(java.lang.Integer productId, java.util.Properties properties, java.lang.String targetFileName)
          Generates new license file.
 java.io.File getAbeonaDirectory()
          Returns directory where is stored Abeona license file and database.
 Database getDatabase()
          Returns product database.
static java.io.InputStream getInputStream(java.lang.String fileName)
          Returns InputStream for given file name.
static Abeona getInstance()
          Returns the default instance of Abeona.
 LicenseGenerator getLicenseGenerator()
          Returns instance of LicenseGenerator.
static java.io.OutputStream getOutputStream(java.lang.String fileName)
          Returns OutputStream for given file name.
 java.lang.String getOwner()
          Returns the owner of this Abeona license or constant UNLICENSED if this is not valid (purchased) license.
 java.lang.String getSerial()
          Returns the serial number of this Abeona license or constant UNLICENSED if this is not valid (purchased) license.
static void main(java.lang.String[] arg)
          Entry point to Abeona application.
static byte[] toBytes(java.lang.String hexadecimalString)
          Converts given hexadecimal String to byte array.
static java.lang.String toString(byte[] array)
          Converts given byte array to hexadecimal String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNLICENSED

public static final java.lang.String UNLICENSED
This constant is returned by method getSerial() if Abeona is running in unlicensed mode.

See Also:
Constant Field Values
Method Detail

getAbeonaDirectory

public java.io.File getAbeonaDirectory()
Returns directory where is stored Abeona license file and database. This is [user.home]/abeona directory.

Returns:
directory with Abeona database and license

getSerial

public java.lang.String getSerial()
Returns the serial number of this Abeona license or constant UNLICENSED if this is not valid (purchased) license.

Returns:
serial number of Abeona license or UNLICENSED

getOwner

public java.lang.String getOwner()
Returns the owner of this Abeona license or constant UNLICENSED if this is not valid (purchased) license.

Returns:
owner of Abeona license or UNLICENSED

getLicenseGenerator

public LicenseGenerator getLicenseGenerator()
Returns instance of LicenseGenerator.

Returns:
license generator

getDatabase

public Database getDatabase()
Returns product database. Database is already open.

Returns:
product database

generateLicense

public void generateLicense(java.lang.Integer productId,
                            java.util.Properties properties,
                            java.lang.String targetFileName)
                     throws LicenseException,
                            java.io.IOException
Generates new license file. You can use this method in server environment:
 Properties properties = new Properties ();
 properties.setProperty ("customer", "Very Big Company");
 properties.setProperty ("dbAccess", "enabled");
 properties.setProperty ("netUpdate", "disabled");
 properties.setProperty ("user.count", "25");
 Abeona instance = Abeona.getInstance ();
 instance.generateLicense (selectedProductId, properties, "d:/licenses/file001.license");
 

Parameters:
productId - - identifier of Product for which should be generated new license
properties - - properties (names and values) to protect by Abeona system
targetFileName - - qualified name of the file to which should be generated license
Throws:
LicenseException - if cannot find Product with given productId or if cannot generate license
java.io.IOException - if there is some I/O problem

getInputStream

public static java.io.InputStream getInputStream(java.lang.String fileName)
Returns InputStream for given file name. First it tries to find file in filesystem and if not found, it searches on classpath.

Parameters:
fileName - name of input file
Returns:
open input stream for requested file or null if not found

getOutputStream

public static java.io.OutputStream getOutputStream(java.lang.String fileName)
Returns OutputStream for given file name. Creates missing directories and then create output file.

Parameters:
fileName - full name of output file
Returns:
open output stream for requested file or null if cannot write

computeSignature

public static byte[] computeSignature(byte[] data)
Computes MD5 hash signature for given data.

Parameters:
data - byte array for which is computed MD5 hash
Returns:
computed MD5 hash (array of 32 bytes)

buildPublicKey

public static java.security.interfaces.RSAPublicKey buildPublicKey(java.lang.String data)
Builds public key (as instance of RSAPublicKey) from given hexadecimal String.

Parameters:
data - encoded public key as is contained in Product.
Returns:
instance of RSAPublicKey
Throws:
java.lang.RuntimeException - if cannot convert given String to instance of RSAPublicKey

buildPrivateKey

public static java.security.interfaces.RSAPrivateKey buildPrivateKey(java.lang.String data)
Builds public key (as instance of RSAPrivateKey) from given hexadecimal String.

Parameters:
data - encoded private key as is contained in Product.
Returns:
instance of RSAPrivateKey
Throws:
java.lang.RuntimeException - if cannot convert given String to instance of RSAPrivateKey

encrypt

public static byte[] encrypt(byte[] data,
                             java.security.Key key)
Encrypts given data with given key. This is RSA one-way (assymetric) encryption.
Warning: Java has limited size of encrypted data to 117 bytes.

Parameters:
data - data to encrypt
key - instance of RSAPublicKey or RSAPrivateKey
Returns:
encrypted data
Throws:
java.lang.RuntimeException - if cannot encrypt data

decrypt

public static byte[] decrypt(byte[] data,
                             java.security.Key key)
Decrypts given data with given key. This is RSA one-way (assymetric) decryption. If you use private key to encrypt data, you must use public key to decrypt them.

Parameters:
data - data to decrypt
key - instance of RSAPublicKey or RSAPrivateKey
Returns:
decrypted data
Throws:
java.lang.RuntimeException - if cannot decrypt data

toString

public static java.lang.String toString(byte[] array)
Converts given byte array to hexadecimal String.

Parameters:
array - data to convert
Returns:
converted String

toBytes

public static byte[] toBytes(java.lang.String hexadecimalString)
Converts given hexadecimal String to byte array.

Parameters:
hexadecimalString - data to convert
Returns:
converted byte array

getInstance

public static Abeona getInstance()
Returns the default instance of Abeona.

Returns:
default instance of Abeona

main

public static void main(java.lang.String[] arg)
Entry point to Abeona application.
When invoked without arguments, GUI tool is started. As argument you can use qualified name of any class, then that class is instanced and invoked.
If you can deliver the control to your class, such class must have one-argument constructor, where argument is type of Abeona.

Parameters:
arg - no arguments or name of class to control

Abeona 2012.1 API