com.vs.ezlicrun
Class EzLicenseInfo

java.lang.Object
  |
  +--com.vs.ezlicrun.EzLicenseInfo
All Implemented Interfaces:
java.io.Serializable

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

The class manages the state of the information pertaining to a license key and provides a method to check a license key. How to use for checking a license key in an ISV product:
1. Instantiate this class: info = new EzLicenseInfo();
2. Check the license key: int warningBitmap = info.checkLicenseKey( licenseKey, etc.);
3. If no exception, the key is good, and the accessors for the class can be invoked to obtain the decomposed info such as quota limit, expiration date, concurrent-user limit, etc.
4. If the returned warning bit map is non-zero, appropriate warning messages / alerts may be issued by the ISV application to the end user informing them of impending expirations, quota exhaustion, etc.

See Also:
Serialized Form

Field Summary
static int EZLIC_MODE_CUSTOM_COOKIE
          Custom cookie
static int EZLIC_MODE_CUSTOM_KEY
          Custom key
static int EZLIC_MODE_METERED
          Metered
static int EZLIC_MODE_OPTIONS
          Option-enabling
static int EZLIC_MODE_TIME
          Time limited
static int EZLIC_MODEL_SERVER
          Server license model
static int EZLIC_MODEL_USER
          Single-user license model
static int EZLIC_TYPE_SVR_CONC
          Concurrent user
static int EZLIC_TYPE_SVR_CPU
          CPU count
static int EZLIC_TYPE_SVR_MHZ
          CPU MHZ
static int EZLIC_TYPE_SVR_NMU
          Named-user
static int EZLIC_TYPE_U_FLOAT
          Floating
static int EZLIC_TYPE_U_NODE
          Node-locked
static int EZLIC_TYPE_U_USER
          User-locked
 
Constructor Summary
EzLicenseInfo()
           
 
Method Summary
 int checkLicenseKey(java.lang.String licenseKey, EzLicCustomLicenseInterface customKeyHandler, java.lang.Object customKeyContext, int daysLeftThreshold, long quotaUsageToDate, long quotaThreshold, int daysGracePeriod, long quotaGrace, java.lang.String userHostNet, long currUsageValue)
          (Full version:) Check the specified license key against the provided info for key violations, and sets the class context based on the key.
 java.lang.String checkLicenseKeySecure(java.lang.String licenseKey, java.lang.String keyCookie, EzLicExceptionBase customException, EzLicCustomLicenseInterface customKeyHandler, java.lang.Object customKeyContext, int daysLeftThreshold, long quotaUsageToDate, long quotaThreshold, int daysGracePeriod, long quotaGrace, java.lang.String userHostNet, long currUsageValue)
          (Secure version:) Check the specified license key against the provided info for key violations, and sets the class context based on the key.
 int checkMultiUserLicenseKeyBasic(java.lang.String licenseKey, int daysLeftThreshold, long quotaUsageToDate, long quotaThreshold, int daysGracePeriod, long quotaGrace, java.lang.String hostNetName, long currUsageValue)
          (Basic multi-user license check:) Check the specified license key against the provided info for key violations, and sets the class context based on the key.
 int checkSingleUserLicenseKeyBasic(java.lang.String licenseKey, int daysLeftThreshold, long quotaUsageToDate, long quotaThreshold, int daysGracePeriod, long quotaGrace, java.lang.String userHostName)
          (Basic single-user license check:) Check the specified license key against the provided info for key violations, and sets the class context based on the key.
static java.lang.String createKeyCookieSeed(java.lang.String userHost)
          createKeyCookieSeed: Create a key cookie seed that is the first key cookie passed into the "checkLicenseKeySecure" API call by an application.
 java.lang.String getCustomCookie()
          getCustomCookie: returns custom cookie contained in the license key, null if none
 java.lang.String getCustomKey()
          getCustomKey: returns custom key contained in the license key, null if none
 boolean getEnforce()
          getEnforce: returns whether user / host name check is enforced
 java.util.Date getExpirationDate()
          getExpirationDate: returns expiration date, null if none
 java.lang.String getLicenseKey()
          getLicenseKey: returns license key
 int getLicenseModeBitmap()
          getLicenseModeBitmap: returns license mode bitmap, bits set per EZLIC_MODE_*.
 int getLicenseModelCode()
          getLicenseModelCode: returns license model code
 int getLicenseTypeCode()
          getLicenseTypeCode: returns license type code
 java.lang.String getOptions()
          getOptions: returns options string, null if none
 long getQuotaValue()
          getQuotaValue: returns quota limit value, -1 if no quota limit.
 long getUsageValue()
          getUsageValue: returns usage limit value (cpu / CPU MHZ etc.) for the license key, -1 if no limit.
 java.lang.String getUserHostNetName()
          getUserOrHostName: returns user / host name, null if none
 int getWarningsBitmap()
          getWarningsBitmap: returns warning bitmap for license key
 void setCustomCookie(java.lang.String customCookie)
          setCustomCookie: sets custom cookie value
 void setCustomKey(java.lang.String customKey)
          setCustomKey: sets custom key value
 void setEnforce(boolean enforce)
          setEnforce: sets user / host enforcement policy
 void setExpirationDate(java.util.Date expirationDate)
          setExpirationDate: sets license expiration date
 void setLicenseKey(java.lang.String licenseKey)
          setLicenseKey: sets license key
 void setLicenseModeBitmap(int licenseModeBitmap)
          setLicenseModeBitmap: sets license mode bitmap
 void setLicenseModelCode(int licenseModelCode)
          setLicenseModelCode: sets license model code
 void setLicenseTypeCode(int licenseTypeCode)
          setLicenseTypeCode: sets license type code
 void setOptions(java.lang.String options)
          setOptions: sets options string
 void setQuotaValue(long quotaValue)
          setQuotaValue: sets usage quota value
 void setUsageValue(long usageValue)
          setUsageValue: sets value for usage limit
 void setUserHostNetName(java.lang.String userHostNetName)
          setUserHostNetName: sets user / host / network name according to context
 void setWarningsBitmap(int warningsBitmap)
          setWarningsBitmap: sets warning bitmap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EZLIC_MODEL_USER

public static final int EZLIC_MODEL_USER
Single-user license model

EZLIC_MODEL_SERVER

public static final int EZLIC_MODEL_SERVER
Server license model

EZLIC_TYPE_U_USER

public static final int EZLIC_TYPE_U_USER
User-locked

EZLIC_TYPE_U_NODE

public static final int EZLIC_TYPE_U_NODE
Node-locked

EZLIC_TYPE_U_FLOAT

public static final int EZLIC_TYPE_U_FLOAT
Floating

EZLIC_TYPE_SVR_CONC

public static final int EZLIC_TYPE_SVR_CONC
Concurrent user

EZLIC_TYPE_SVR_CPU

public static final int EZLIC_TYPE_SVR_CPU
CPU count

EZLIC_TYPE_SVR_MHZ

public static final int EZLIC_TYPE_SVR_MHZ
CPU MHZ

EZLIC_TYPE_SVR_NMU

public static final int EZLIC_TYPE_SVR_NMU
Named-user

EZLIC_MODE_TIME

public static final int EZLIC_MODE_TIME
Time limited

EZLIC_MODE_METERED

public static final int EZLIC_MODE_METERED
Metered

EZLIC_MODE_OPTIONS

public static final int EZLIC_MODE_OPTIONS
Option-enabling

EZLIC_MODE_CUSTOM_KEY

public static final int EZLIC_MODE_CUSTOM_KEY
Custom key

EZLIC_MODE_CUSTOM_COOKIE

public static final int EZLIC_MODE_CUSTOM_COOKIE
Custom cookie
Constructor Detail

EzLicenseInfo

public EzLicenseInfo()
Method Detail

getLicenseKey

public java.lang.String getLicenseKey()
getLicenseKey: returns license key
Returns:
license key string

getLicenseModelCode

public int getLicenseModelCode()
getLicenseModelCode: returns license model code
Returns:
license model code for the license key

getLicenseTypeCode

public int getLicenseTypeCode()
getLicenseTypeCode: returns license type code
Returns:
license type code for the license key

getLicenseModeBitmap

public int getLicenseModeBitmap()
getLicenseModeBitmap: returns license mode bitmap, bits set per EZLIC_MODE_*.
Returns:
bitmap of license modes for the license key

getCustomKey

public java.lang.String getCustomKey()
getCustomKey: returns custom key contained in the license key, null if none
Returns:
custom key for the license key

getCustomCookie

public java.lang.String getCustomCookie()
getCustomCookie: returns custom cookie contained in the license key, null if none
Returns:
custom cookie for the license key

getUserHostNetName

public java.lang.String getUserHostNetName()
getUserOrHostName: returns user / host name, null if none
Returns:
user / host name for the license key

getExpirationDate

public java.util.Date getExpirationDate()
getExpirationDate: returns expiration date, null if none
Returns:
license model code for the license key

getOptions

public java.lang.String getOptions()
getOptions: returns options string, null if none
Returns:
option string for the license key

getEnforce

public boolean getEnforce()
getEnforce: returns whether user / host name check is enforced
Returns:
whether enforced

getQuotaValue

public long getQuotaValue()
getQuotaValue: returns quota limit value, -1 if no quota limit.
Returns:
quota limit for the license key

getUsageValue

public long getUsageValue()
getUsageValue: returns usage limit value (cpu / CPU MHZ etc.) for the license key, -1 if no limit.
Returns:
usage limit for the license key

getWarningsBitmap

public int getWarningsBitmap()
getWarningsBitmap: returns warning bitmap for license key
Returns:
warning bitmap

setLicenseKey

public void setLicenseKey(java.lang.String licenseKey)
setLicenseKey: sets license key
Parameters:
licenseKey: - the license key

setLicenseModelCode

public void setLicenseModelCode(int licenseModelCode)
setLicenseModelCode: sets license model code
Parameters:
licenseModelCode: - license model code for the license key

setLicenseTypeCode

public void setLicenseTypeCode(int licenseTypeCode)
setLicenseTypeCode: sets license type code
Parameters:
licenseTypeCode: - license type code for the license key

setLicenseModeBitmap

public void setLicenseModeBitmap(int licenseModeBitmap)
setLicenseModeBitmap: sets license mode bitmap
Parameters:
licenseModeBitmap: - license mode bitmap for the license key

setCustomKey

public void setCustomKey(java.lang.String customKey)
setCustomKey: sets custom key value
Parameters:
customKey: - custom key for the license key

setCustomCookie

public void setCustomCookie(java.lang.String customCookie)
setCustomCookie: sets custom cookie value
Parameters:
customCookie: - custom cookie for the license key

setUserHostNetName

public void setUserHostNetName(java.lang.String userHostNetName)
setUserHostNetName: sets user / host / network name according to context
Parameters:
userHostNetName: - user / host / network name

setExpirationDate

public void setExpirationDate(java.util.Date expirationDate)
setExpirationDate: sets license expiration date
Parameters:
expirationDate: - license key expiration date

setOptions

public void setOptions(java.lang.String options)
setOptions: sets options string
Parameters:
options: - String representing options

setEnforce

public void setEnforce(boolean enforce)
setEnforce: sets user / host enforcement policy
Parameters:
enforce: - user / host enforcement policy

setQuotaValue

public void setQuotaValue(long quotaValue)
setQuotaValue: sets usage quota value
Parameters:
quotaValue: - value for usage quota

setUsageValue

public void setUsageValue(long usageValue)
setUsageValue: sets value for usage limit
Parameters:
usageValue: - usage limit value.

setWarningsBitmap

public void setWarningsBitmap(int warningsBitmap)
setWarningsBitmap: sets warning bitmap
Parameters:
warningsBitmap: - warning bitmap

createKeyCookieSeed

public static java.lang.String createKeyCookieSeed(java.lang.String userHost)
createKeyCookieSeed: Create a key cookie seed that is the first key cookie passed into the "checkLicenseKeySecure" API call by an application. An application invokes this method the first time it is executed after receiving a license key, and saves the returned key cookie in persistent store. Subsequently, the value in the persistent store is supplied to the "checkLicenseKeySecure" API call, which upon a successful license key check returns an updated key cookie that the application replaces the previous value with. The combination of the "createKeyCookieSeed" and "checkLicenseKey" API's enables an application to be both spoof-proof and protect itself from hackers turning back the system clock to re-run time-limited copies of programs.
Parameters:
userHost: - the user or host name corresponding to the key
Returns:
generated key cookie string.

checkSingleUserLicenseKeyBasic

public int checkSingleUserLicenseKeyBasic(java.lang.String licenseKey,
                                          int daysLeftThreshold,
                                          long quotaUsageToDate,
                                          long quotaThreshold,
                                          int daysGracePeriod,
                                          long quotaGrace,
                                          java.lang.String userHostName)
                                   throws EzLicExceptionBase
(Basic single-user license check:) Check the specified license key against the provided info for key violations, and sets the class context based on the key. Throws an appropriate exception if the key is invalid or there is a license violation. Returns warning code bitmap to indicate almost-out-of-quota, expiring, etc. conditions that are not yet errors.
Parameters:
licenseKey: - license key.
daysLeftThreshold: - threshold for # of days remaining in a time-limited license in order to trigger an "about-to-expire" warning.
quotaUsageToDate: - amount of used quota to date expressed in license units, if this is expected to be a metered license.
quotaThreshold: - threshold for # of license units remaining in a metered license in order to trigger an "about-to-expire" warning.
userHostName: - user or host name, for a user / node locked license.
Returns:
bitmap of warning codes, 0 if none. Warning codes are per those defined in EzLicExceptionBase, possibly augmented by ISV's custom warning codes for use in conjunction with custom key handler.
Throws:
EzLicExceptionBase - in the event of a malformed key or invalid license.
See Also:
EzLicExceptionBase

checkMultiUserLicenseKeyBasic

public int checkMultiUserLicenseKeyBasic(java.lang.String licenseKey,
                                         int daysLeftThreshold,
                                         long quotaUsageToDate,
                                         long quotaThreshold,
                                         int daysGracePeriod,
                                         long quotaGrace,
                                         java.lang.String hostNetName,
                                         long currUsageValue)
                                  throws EzLicExceptionBase
(Basic multi-user license check:) Check the specified license key against the provided info for key violations, and sets the class context based on the key. Throws an appropriate exception if the key is invalid or there is a license violation. Returns warning code bitmap to indicate almost-out-of-quota, expiring, etc. conditions that are not yet errors.
Parameters:
licenseKey: - license key.
daysLeftThreshold: - threshold for # of days remaining in a time-limited license in order to trigger an "about-to-expire" warning.
quotaUsageToDate: - amount of remaining quota expressed in license units, if this is expected to be a metered license.
quotaThreshold: - threshold for # of license units remaining in a metered license in order to trigger an "about-to-expire" warning.
hostNetName: - (floating) network or (server) host name for floating / server license.
currUsageValue: - current usage value for floating / concurrent-user / cpu / mhz usage models.
Returns:
bitmap of warning codes, 0 if none. Warning codes are per those defined in EzLicExceptionBase, possibly augmented by ISV's custom warning codes for use in conjunction with custom key handler.
Throws:
EzLicExceptionBase - in the event of a malformed key or invalid license.
See Also:
EzLicExceptionBase

checkLicenseKey

public int checkLicenseKey(java.lang.String licenseKey,
                           EzLicCustomLicenseInterface customKeyHandler,
                           java.lang.Object customKeyContext,
                           int daysLeftThreshold,
                           long quotaUsageToDate,
                           long quotaThreshold,
                           int daysGracePeriod,
                           long quotaGrace,
                           java.lang.String userHostNet,
                           long currUsageValue)
                    throws EzLicExceptionBase
(Full version:) Check the specified license key against the provided info for key violations, and sets the class context based on the key. Throws an appropriate exception if the key is invalid or there is a license violation. Returns warning code bitmap to indicate almost-out-of-quota, expiring, etc. conditions that are not yet errors.
Parameters:
licenseKey: - license key.
customKeyHandler: - optional custom license key handler for processing custom key in an ISV specific manner. Null if not specified.
customKeyContext: - optional run time context for custom license key handler above.
daysLeftThreshold: - threshold for # of days remaining in a time-limited license in order to trigger an "about-to-expire" warning.
quotaUsageToDate: - amount of remaining quota expressed in license units, if this is expected to be a metered license.
quotaThreshold: - threshold for # of license units remaining in a metered license in order to trigger an "about-to-expire" warning.
daysGracePeriod: - grace period for time limited license - if today is past expiration date by less than this many days, set a warning instead of throwing an exception.
quotaGrace: - grace quota - if quota is exceeded by less than this amount, set a warning instead of throwing an exception.
userHostNet: - user or host or network name, for a user / node locked / floating license.
currUsageValue: - current usage value for floating / concurrent-user / cpu / mhz usage models.
Returns:
bitmap of warning codes, 0 if none. Warning codes are per those defined in EzLicExceptionBase, possibly augmented by ISV's custom warning codes for use in conjunction with custom key handler.
Throws:
EzLicExceptionBase - in the event of a malformed key or invalid license.
See Also:
EzLicExceptionBase

checkLicenseKeySecure

public java.lang.String checkLicenseKeySecure(java.lang.String licenseKey,
                                              java.lang.String keyCookie,
                                              EzLicExceptionBase customException,
                                              EzLicCustomLicenseInterface customKeyHandler,
                                              java.lang.Object customKeyContext,
                                              int daysLeftThreshold,
                                              long quotaUsageToDate,
                                              long quotaThreshold,
                                              int daysGracePeriod,
                                              long quotaGrace,
                                              java.lang.String userHostNet,
                                              long currUsageValue)
                                       throws EzLicExceptionBase
(Secure version:) Check the specified license key against the provided info for key violations, and sets the class context based on the key. Throws an appropriate exception if the key is invalid or there is a license violation. Returns warning code bitmap to indicate almost-out-of-quota, expiring, etc. conditions that are not yet errors.
Parameters:
licenseKey: - license key.
keyCookie: - the key cookie that was returned from the previous call to this method for this key, or from the createKeyCookieSeed() method if none.
customException: - a "success" exception class custom-defined by the application to be a subclass of EzLicExceptionBase. If the caller catches this exception, it signifies success, in which case the handler's "getMessage()" method returns the new cookie, and its "getMessageCode()" method returns the warning bitmap. If a null handler is specified, control returns normally from this call with the new cookie as the return value. The reason for specifying a custom exception handler is to help foil attempts at hacking the application code by manipulating binary code that corresponds to the check for the return value of the license key check call.
customKeyHandler: - optional custom license key handler for processing custom key in an ISV specific manner. Null if not specified.
customKeyContext: - optional run time context for custom license key handler above.
daysLeftThreshold: - threshold for # of days remaining in a time-limited license in order to trigger an "about-to-expire" warning.
quotaUsageToDate: - amount of remaining quota expressed in license units, if this is expected to be a metered license.
quotaThreshold: - threshold for # of license units remaining in a metered license in order to trigger an "about-to-expire" warning.
daysGracePeriod: - grace period for time limited license - if today is past expiration date by less than this many days, set a warning instead of throwing an exception.
quotaGrace: - grace quota - if quota is exceeded by less than this amount, set a warning instead of throwing an exception.
userHostNet: - user or host or network name, for a user / node locked / floating license.
currUsageValue: - current usage value for floating / concurrent-user / cpu / mhz usage models.
Returns:
new key cookie value, if the license key check is successful and a null custom exception handler is provided.
Throws:
EzLicExceptionBase - in the event of a malformed key or invalid license, and also in the event of a successful license key when a non-null custom exception class is provided.
See Also:
EzLicExceptionBase