Home about services products contact login
   com.smardec

License4J

  license4j
com.smardec.license4j
Class LicenseUtil

java.lang.Object
|
+--com.smardec.license4j.LicenseUtil

public final class LicenseUtil
extends java.lang.Object

Provides utility methods for generating key pair and for signing arbitrary user content.


Method Summary
static java.lang.String[] createKeyPair()
Creates key pair and and returns it as an array of strings.
static void createKeyPair(java.lang.String filename)
Creates key pair and saves it to the specified file.
static void createKeyPair(java.io.Writer writer)
Creates key pair and saves it to the specified Writer.
static java.lang.String getMacAddress()
The method returns host MAC address.
static java.util.Vector getMacAddresses()
The method returns all MAC addresses of the host.
static java.lang.String sign(byte[] message, java.lang.String privateKey)
The method allows to sign arbitrary content using private key.
static java.lang.String sign(java.lang.String message, java.lang.String privateKey)
The method allows to sign arbitrary content using private key.
static boolean verify(byte[] message, java.lang.String signature, java.lang.String publicKey)
The method allows to verify the signature of the specified data using public key.
static boolean verify(java.lang.String message, java.lang.String signature, java.lang.String publicKey)
The method allows to verify the signature of the specified data using public key.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Detail
createKeyPair
public static void createKeyPair(java.lang.String filename)

Creates key pair and saves it to the specified file.

Parameters:
filename - name of the file

createKeyPair
public static void createKeyPair(java.io.Writer writer)
Creates key pair and saves it to the specified Writer. Note that Writer.close() method is not invoked after writing the keys.

Parameters:
writer - Writer that will contain public and private keys

createKeyPair
public static java.lang.String[] createKeyPair()
Creates key pair and and returns it as an array of strings. The first element in the array is public key and the second element is private key.

Returns:
array that contains public and private keys respectively.

sign
public static java.lang.String sign(java.lang.String message, java.lang.String privateKey) throws java.security.GeneralSecurityException
The method allows to sign arbitrary content using private key. Validity can be verified using verify(String, String, String).

Parameters:
message - data to sign
privateKey - private key
Returns:
signature of the specified data.
Throws:
java.security.GeneralSecurityException - if errors occured during signing

sign
public static java.lang.String sign(byte[] message, java.lang.String privateKey) throws java.security.GeneralSecurityException
The method allows to sign arbitrary content using private key. Validity can be verified using verify(String, String, String).

Parameters:
message - data to sign
privateKey - private key
Returns:
signature of the specified data.
Throws:
java.security.GeneralSecurityException - if errors occured during signing

verify
public static boolean verify(java.lang.String message, java.lang.String signature, java.lang.String publicKey) throws java.security.GeneralSecurityException
The method allows to verify the signature of the specified data using public key. The data can be signed using sign(String, String).

Parameters:
message - signed data
signature - data's signature
publicKey - public key
Returns:
true if the signature was verified, false otherwise.
Throws:
java.security.GeneralSecurityException - if errors occured during verification process

verify
public static boolean verify(byte[] message, java.lang.String signature, java.lang.String publicKey) throws java.security.GeneralSecurityException
The method allows to verify the signature of the specified data using public key. The data can be signed using sign(String, String).

Parameters:
message - signed data
signature - data's signature
publicKey - public key
Returns:
true if the signature was verified, false otherwise.
Throws:
java.security.GeneralSecurityException - if errors occured during verification process

getMacAddress
public static java.lang.String getMacAddress()
The method returns host MAC address.

Returns:
MAC address string or null if error occured.

getMacAddresses
public static java.util.Vector getMacAddresses()
The method returns all MAC addresses of the host.

Returns:
Vector of Strings.
Home about services products contact login