main
Class LicenseChecker

java.lang.Object
  extended by main.LicenseChecker
All Implemented Interfaces:
java.io.Serializable

public class LicenseChecker
extends java.lang.Object
implements java.io.Serializable

Class that is able to read, check, and create license key files.

See Also:
LicenseKey, Serialized Form

Field Summary
private  boolean licenseAccepted
          Stores whether the license was accepted by the user.
private  java.lang.String licenseFileName
          The license file name.
private static boolean printLog
          Flag to enable debug message printing for this class.
(package private) static long serialVersionUID
          The version tracking unique identifier for Serialization.
 
Constructor Summary
LicenseChecker()
          Instantiates a new license checker.
 
Method Summary
private static long byte2Long(byte[] addr)
          Converts Byte data to an address in long format.
 boolean checkHostid(LicenseKey key)
          Checks whether the MAC address of this machine matches the MAC adress in the license file.
 boolean checkUsername(LicenseKey key)
          Checks, whether the current username matches one of the usernames stored in the license key.
 boolean createKeyFile(LicenseKey key)
          Creates a new license key file after the user confirmed that he agrees to the license.
private  void log(java.lang.String message)
          Prints debug information to stdout when printLog is set to true.
static java.lang.String macAdressToString(byte[] macAddress)
          Converts a Mac adress to a string.
 LicenseKey readKeyFile()
          Reads information from a license key file.
 void setLicenseAccepted(boolean licenseAccepted)
          Specifies whether the license was accepted.
private static long unsignedByteToLong(byte b)
          Unsigned byte to long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
The version tracking unique identifier for Serialization.

See Also:
Constant Field Values

printLog

private static final boolean printLog
Flag to enable debug message printing for this class.

See Also:
Constant Field Values

licenseAccepted

private boolean licenseAccepted
Stores whether the license was accepted by the user.


licenseFileName

private java.lang.String licenseFileName
The license file name.

Constructor Detail

LicenseChecker

public LicenseChecker()
Instantiates a new license checker.

Method Detail

createKeyFile

public boolean createKeyFile(LicenseKey key)
Creates a new license key file after the user confirmed that he agrees to the license.

Parameters:
key - the license key key
Returns:
true, if successful

readKeyFile

public LicenseKey readKeyFile()
                       throws java.io.InvalidClassException,
                              java.io.IOException
Reads information from a license key file.

Returns:
the license key
Throws:
java.io.InvalidClassException - the invalid class exception
java.io.IOException - Signals that an I/O exception has occurred.

checkHostid

public boolean checkHostid(LicenseKey key)
Checks whether the MAC address of this machine matches the MAC adress in the license file.

Parameters:
key - the license key
Returns:
true, if a match was found

checkUsername

public boolean checkUsername(LicenseKey key)
Checks, whether the current username matches one of the usernames stored in the license key.

This ensures that every user on this machine has to accept the license agreement.

Parameters:
key - the license key
Returns:
true, if successful

macAdressToString

public static java.lang.String macAdressToString(byte[] macAddress)
Converts a Mac adress to a string.

Parameters:
macAddress - the mac address
Returns:
the string

byte2Long

private static long byte2Long(byte[] addr)
Converts Byte data to an address in long format.

Parameters:
addr - the byte array
Returns:
the address

unsignedByteToLong

private static long unsignedByteToLong(byte b)
Unsigned byte to long.

Parameters:
b - the byte
Returns:
the long value

setLicenseAccepted

public void setLicenseAccepted(boolean licenseAccepted)
Specifies whether the license was accepted.

Parameters:
licenseAccepted - Specifies whether the license was accepted.

log

private void log(java.lang.String message)
Prints debug information to stdout when printLog is set to true.

Parameters:
message - the message