com.jp.protection.pub.pro
Class LicenseHostProContext

java.lang.Object
  extended by com.jp.protection.pub.pro.LicenseHostProContext
Direct Known Subclasses:
Java6LicenseHostProContext

public class LicenseHostProContext
extends java.lang.Object

This class represents context for the License Host by providing access to various system and application properties

Since:
3.0

Field Summary
static java.lang.String ATTR_AVAILABLE_PROCESSORS
           
static java.lang.String ATTR_HOST_NAME
           
static java.lang.String ATTR_INSTALL_ID
           
static java.lang.String ATTR_IP_ADDRESS
           
static java.lang.String ATTR_LOCALE
           
static java.lang.String ATTR_MAC_ADDRESS
           
static java.lang.String ATTR_MAC_ADDRESSES
           
static java.lang.String ATTR_USER_NAME
           
protected  LicenseHostPro fLicenseHost
           
protected  boolean fVerbose
           
 
Constructor Summary
LicenseHostProContext(LicenseHostPro aLicenseHost)
          Creates a new instance of context.
 
Method Summary
 java.util.Map createAttributes(boolean isAcquireMACAddress)
          Returns the map of attributes.
 java.util.Map createAttributes(java.lang.String aPrefix, boolean isAcquireMACAddress)
          Returns the map of attributes.
protected  void error(java.lang.String aMessage)
           
protected  void error(java.lang.Throwable ex)
           
 void fillAttributes(java.util.Map anAttributes, java.lang.String aPrefix, boolean isAcquireMACAddress)
          Fill the map with attributes.
 int getActivationNumber(java.lang.String aLicenseNumber)
          Returns the activation number for the given license number
protected static java.lang.String getAttributeName(java.lang.String aName, java.lang.String aPrefix, java.lang.String aSuffix)
           
 int getAvailableProcessors()
          Returns number of the available processors.
 java.lang.String getCpuID()
          Returns CPU ID
 java.lang.String getCustomLockAttribute()
          Returns custom lock attribute
 java.lang.String getHostName()
          Returns the name of the local host
 java.lang.String[] getHostNames()
          Returns possible names of the local host
 int getInstallID()
          Returns the installation ID
 java.lang.String getIPAddress()
          Returns IP address of the local host
 long getMACAddress()
          Returns MAC address of primary network card
 long[] getMACAddresses()
          Returns MAC addresses of all network cards
 java.lang.String getMotherboardID()
          Returns motherboard ID
 java.lang.String getSystemProperty(java.lang.String aName, java.lang.String aDefaultValue)
          Returns the system property indicated by the specified key.
 long getTotalPhysicalMemorySize()
          Returns total physical memory size in bytes
 java.lang.String getUserName()
          Returns login name of the current user
 boolean isVerbose()
          Checks whether the context runs in verbose mode.
 void setActivationNumber(java.lang.String aLicenseNumber, int aValue)
          Specifies the activation number for the give license number
static void setNativeLibFolder(java.io.File aFolder)
          Specifies location of the folder containing native libraries used to obtain MAC addresses.
 void setVerbose(boolean aVerbose)
          Specifies that the context should run in verbose mode.
static java.lang.String unqualifiedHostName(java.lang.String aHostName)
          Returns unqualified host name: example for example.domain.com
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_AVAILABLE_PROCESSORS

public static final java.lang.String ATTR_AVAILABLE_PROCESSORS
See Also:
Constant Field Values

ATTR_IP_ADDRESS

public static final java.lang.String ATTR_IP_ADDRESS
See Also:
Constant Field Values

ATTR_HOST_NAME

public static final java.lang.String ATTR_HOST_NAME
See Also:
Constant Field Values

ATTR_MAC_ADDRESS

public static final java.lang.String ATTR_MAC_ADDRESS
See Also:
Constant Field Values

ATTR_MAC_ADDRESSES

public static final java.lang.String ATTR_MAC_ADDRESSES
See Also:
Constant Field Values

ATTR_INSTALL_ID

public static final java.lang.String ATTR_INSTALL_ID
See Also:
Constant Field Values

ATTR_USER_NAME

public static final java.lang.String ATTR_USER_NAME
See Also:
Constant Field Values

ATTR_LOCALE

public static final java.lang.String ATTR_LOCALE
See Also:
Constant Field Values

fLicenseHost

protected LicenseHostPro fLicenseHost

fVerbose

protected boolean fVerbose
Constructor Detail

LicenseHostProContext

public LicenseHostProContext(LicenseHostPro aLicenseHost)
Creates a new instance of context.

Parameters:
aLicenseHost - License Host to create context for
Method Detail

getAttributeName

protected static java.lang.String getAttributeName(java.lang.String aName,
                                                   java.lang.String aPrefix,
                                                   java.lang.String aSuffix)

createAttributes

public java.util.Map createAttributes(boolean isAcquireMACAddress)
Returns the map of attributes.

Parameters:
isAcquireMACAddress - specifies whether MAC address of network card should be acquired and put to result.
Returns:
map of attributes.

createAttributes

public java.util.Map createAttributes(java.lang.String aPrefix,
                                      boolean isAcquireMACAddress)
Returns the map of attributes.

Parameters:
aPrefix - optional prefix to add to each attribute name
isAcquireMACAddress - specifies whether MAC address of network card should be acquired and put to result.
Returns:
map of attributes.

fillAttributes

public void fillAttributes(java.util.Map anAttributes,
                           java.lang.String aPrefix,
                           boolean isAcquireMACAddress)
Fill the map with attributes.

Parameters:
aPrefix - optional prefix to add to each attribute name
isAcquireMACAddress - specifies whether MAC address of network card should be acquired and put to result.

getUserName

public java.lang.String getUserName()
Returns login name of the current user

Returns:
login name of the current user

getSystemProperty

public java.lang.String getSystemProperty(java.lang.String aName,
                                          java.lang.String aDefaultValue)
Returns the system property indicated by the specified key.

Parameters:
key - the name of the system property.
def - a default value.
Returns:
the string value of the system property, or the default value if there is no property with that key.

getAvailableProcessors

public int getAvailableProcessors()
Returns number of the available processors.

Returns:
number of the available processors

getIPAddress

public java.lang.String getIPAddress()
                              throws java.net.UnknownHostException
Returns IP address of the local host

Returns:
IP address of the local host
Throws:
java.net.UnknownHostException - if local host could not be obtained

getHostName

public java.lang.String getHostName()
                             throws java.net.UnknownHostException
Returns the name of the local host

Returns:
name of the local host.
Throws:
java.net.UnknownHostException - if local host could not be obtained

getHostNames

public java.lang.String[] getHostNames()
                                throws java.net.UnknownHostException
Returns possible names of the local host

Returns:
possible names of the local host
Throws:
java.net.UnknownHostException
Since:
v5

unqualifiedHostName

public static java.lang.String unqualifiedHostName(java.lang.String aHostName)
Returns unqualified host name: example for example.domain.com

Parameters:
aHostName - qualified host name
Returns:
unqualified host name
Since:
5.0

getMACAddress

public long getMACAddress()
Returns MAC address of primary network card

Returns:
MAC address of primary network card

getMACAddresses

public long[] getMACAddresses()
Returns MAC addresses of all network cards

Returns:
MAC addresses of all network cards

getCpuID

public java.lang.String getCpuID()
Returns CPU ID

Returns:
CPU ID
Since:
4.9.0

getMotherboardID

public java.lang.String getMotherboardID()
Returns motherboard ID

Returns:
motherboard ID
Since:
4.9.0

getTotalPhysicalMemorySize

public long getTotalPhysicalMemorySize()
Returns total physical memory size in bytes

Returns:
total physical memory size in bytes
Since:
5.0

getCustomLockAttribute

public java.lang.String getCustomLockAttribute()
Returns custom lock attribute

Returns:
custom lock attribute
Since:
4.9.0

getInstallID

public int getInstallID()
Returns the installation ID

Returns:
installation ID

getActivationNumber

public int getActivationNumber(java.lang.String aLicenseNumber)
Returns the activation number for the given license number

Parameters:
aLicenseNumber - license number
Returns:
activation number

setActivationNumber

public void setActivationNumber(java.lang.String aLicenseNumber,
                                int aValue)
Specifies the activation number for the give license number

Parameters:
aLicenseNumber - license number
aValue - activation number

setNativeLibFolder

public static void setNativeLibFolder(java.io.File aFolder)
Specifies location of the folder containing native libraries used to obtain MAC addresses.

Parameters:
aFolder - native libraries folder

isVerbose

public boolean isVerbose()
Checks whether the context runs in verbose mode.

Returns:
true if context runs in verbose mode, false otherwise.

setVerbose

public void setVerbose(boolean aVerbose)
Specifies that the context should run in verbose mode. If it runs in verbose mode all exceptions stack traces and error messages will be printed to std err. Otherwise there is no output in order to prevent the code flow analysis.

Parameters:
aVerbose - true if context should run in verbose mode, false otherwise.

error

protected void error(java.lang.String aMessage)

error

protected void error(java.lang.Throwable ex)