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.


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.
 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.
 LicenseGenerator getLicenseGenerator()
          Returns instance of LicenseGenerator.
static java.io.OutputStream getOutputStream(java.lang.String fileName)
          Returns OutputStream for given file name.
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
 

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

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

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

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