eu.beesoft.abeona
Class License

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

public final class License
extends java.lang.Object

This is class for obtaining license properties. Each property is [name : value] pair (as String instances), backed by java.util.Properties class. One of the properties should be 'Abeona.Signature' property generated by LicenseGenerator. This property is used to check license validity in method isValid().

There are three load() methods to fill license properties:

If there is any problem with license properties loading, LicenseException is thrown. This exception is also thrown when getProperty(String) method is invoked and properties are not valid.


Field Summary
static java.lang.String OWNER
          Constant for 'Abeona.Owner' name.
static java.lang.String SERIAL_NUMBER
          Constant for 'Abeona.Serial.Number' name.
static java.lang.String SIGNATURE
          Constant for 'Abeona.Signature' name.
 
Constructor Summary
License()
          Default constructor - creates new instance of License.
 
Method Summary
static java.lang.String getMacAddress()
          Returns MAC address of computer (more precise - its network card).
 java.lang.String getProperty(java.lang.String name)
          Returns from license file value for given property name.
 java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Returns from license file value for given property name.
 java.util.List<java.lang.String> getPropertyNames()
          Returns from license file all property names.
static java.lang.String getUserName()
          Returns user name from system properties.
 boolean isValid()
          Checks license validity and returns result.
 void load(java.io.InputStream inputStream, java.lang.String publicKey)
          Loads license properties from given input stream and checks their digital signature.
 void load(java.util.Properties properties, java.lang.String publicKey)
          Loads license properties from given properties and checks their digital signature.
 void load(java.lang.String host, java.lang.String port, java.lang.String applicationName, java.lang.String publicKey)
          Loads license properties from license server and - if required - checks their digital signature.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIGNATURE

public static final java.lang.String SIGNATURE
Constant for 'Abeona.Signature' name.

See Also:
Constant Field Values

SERIAL_NUMBER

public static final java.lang.String SERIAL_NUMBER
Constant for 'Abeona.Serial.Number' name.

See Also:
Constant Field Values

OWNER

public static final java.lang.String OWNER
Constant for 'Abeona.Owner' name.

See Also:
Constant Field Values
Constructor Detail

License

public License()
Default constructor - creates new instance of License.

Method Detail

load

public void load(java.io.InputStream inputStream,
                 java.lang.String publicKey)
          throws LicenseException
Loads license properties from given input stream and checks their digital signature.

Parameters:
inputStream - stream to load properties from
publicKey - public key String to signature check
Throws:
LicenseException - when some of arguments is null, I/O error occurred or signature is invalid

load

public void load(java.util.Properties properties,
                 java.lang.String publicKey)
          throws LicenseException
Loads license properties from given properties and checks their digital signature.

Parameters:
properties - properties to load license from
publicKey - public key String to signature check
Throws:
LicenseException - when some of arguments is null, I/O error occurred or signature is invalid

load

public void load(java.lang.String host,
                 java.lang.String port,
                 java.lang.String applicationName,
                 java.lang.String publicKey)
          throws LicenseException
Loads license properties from license server and - if required - checks their digital signature.

Parameters:
host - server name or its IP address (like 127.0.0.1)
port - server port to connect (like 6565)
applicationName - name of application for which is license requested
publicKey - public key String to signature check. If null, there is no check executed and method getProperty(String) never throws LicenseException.
Throws:
LicenseException - when some of arguments is null, I/O error occurred or signature is invalid

isValid

public boolean isValid()
Checks license validity and returns result. Result is true if and only if:

Returns:
result of license validation (true if valid)

getProperty

public java.lang.String getProperty(java.lang.String name)
                             throws LicenseException
Returns from license file value for given property name.

Parameters:
name - Property name
Returns:
Property value
Throws:
LicenseException - if license is not valid

getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultValue)
                             throws LicenseException
Returns from license file value for given property name.

Parameters:
name - Property name
defaultValue - This value is returned if property with given name does not exist
Returns:
Property value or defaultValue if property does not exist
Throws:
LicenseException - if license is not valid

getPropertyNames

public java.util.List<java.lang.String> getPropertyNames()
                                                  throws LicenseException
Returns from license file all property names.

Returns:
List of signed properties names
Throws:
LicenseException - if license is not valid

getUserName

public static java.lang.String getUserName()
Returns user name from system properties.

Returns:
user name as set in system properties

getMacAddress

public static java.lang.String getMacAddress()
Returns MAC address of computer (more precise - its network card). For Java 1.6 uses JDK built-in method, for older Java version is invoked system command.

Returns:
computer MAC address as String of hecadecimal numbers
Throws:
java.lang.RuntimeException - if cannot obtain MAC address