com.jp.protection.pub
Class LicenseImpl

java.lang.Object
  extended by com.jp.protection.pub.LicenseBaseImpl
      extended by com.jp.protection.pub.LicenseImpl
All Implemented Interfaces:
License, LicenseBase, java.io.Serializable, java.lang.Cloneable

public class LicenseImpl
extends LicenseBaseImpl
implements License, java.lang.Cloneable

This class represents default implementation of the License interface.

See Also:
Serialized Form

Field Summary
protected static java.text.DateFormat DATE_FORMAT
           
protected  java.lang.String fLicenseLocation
           
protected  int fLicenseState
           
protected  java.lang.String fLicenseText
           
protected  java.util.HashMap fProductFeaturesMap
           
protected  java.util.HashMap fProperties
           
static long serialVersionUID
           
static java.lang.String TYPE_STR_COMMERCIAL
           
static java.lang.String TYPE_STR_EVALUATION
           
static java.lang.String TYPE_STR_EXTENDED_EVALUATION
           
static java.lang.String USER_LICENSING_FLOATING_LS_STR
           
static java.lang.String USER_LICENSING_FLOATING_STR
           
static java.lang.String USER_LICENSING_NAMED_LS_STR
           
static java.lang.String USER_LICENSING_NAMED_STR
           
static java.lang.String USER_LICENSING_UNCOUNTED_STR
           
static java.lang.String USER_LICENSING_UNKNOWN_STR
           
 
Fields inherited from class com.jp.protection.pub.LicenseBaseImpl
fGracePeriod, fLicenseExpireDate, fLicenseIssueDate, fLicenseNumber, fLicenseOptions, fLicenseType, fNumberCopies, fProduct, fProductEdition, fProductMajorVersion, fProductMinorVersion, fUserLicensingModel
 
Fields inherited from interface com.jp.protection.pub.License
CASE_COMMERCIAL_ENABLED, CASE_ENABLED, CASE_EVALUATION_ENABLED, CASE_EXPIRED_ENABLED, CASE_EXPIRED_EVALUATION_ENABLED, CASE_INVALID_ENABLED, KIND_NEW, KIND_UPGRADE, NO_LIMIT, NO_USAGE_LIMIT, PREFIX, PROPERTY_ACTIVATION_GRACE_PERIOD, PROPERTY_ACTIVATION_KEY, PROPERTY_ADDRESS, PROPERTY_CHECKOUT_PERIOD, PROPERTY_CITY, PROPERTY_COMPANY, PROPERTY_COUNTRY, PROPERTY_CPU_LIMIT, PROPERTY_EMAIL, PROPERTY_FIRST_NAME, PROPERTY_LAST_NAME, PROPERTY_LICENSE_KIND, PROPERTY_LICENSING_SERVER_ADDRESS, PROPERTY_LOCK_GRACE_PERIOD, PROPERTY_LOCK_PERIOD, PROPERTY_MAIN_LICENSE, PROPERTY_MEMORY_LIMIT, PROPERTY_PHONE, PROPERTY_PREV_LICENSE_MAJOR_VERSION, PROPERTY_PREV_LICENSE_MINOR_PRODUCT_EDITIONS, PROPERTY_PREV_LICENSE_MINOR_VERSION, PROPERTY_SERIAL_NUMBER, PROPERTY_STATE, PROPERTY_TITLE, PROPERTY_USAGE_GRACE_PERIOD, PROPERTY_USAGE_LIMIT, PROPERTY_ZIP, STATE_EXPIRED, STATE_INVALID, STATE_LOCK_VIOLATED, STATE_NOT_ACTIVATED, STATE_NOT_LOCKED, STATE_OK, STATE_UNKNOWN
 
Fields inherited from interface com.jp.protection.pub.LicenseBase
NO_GRACE_PERIOD, OPTION_CHECK_NUMBER_OF_COPIES, OPTION_COUNT_ANY_HOSTS, OPTION_COUNT_DIFF_HOSTS, OPTION_DISALLOW_SEVERAL_COPIES_SAME_HOST, OPTION_REQUIRE_ACTIVATION, OPTION_REQUIRE_ACTIVATION_LOCK, OPTION_REQUIRE_USER_INFO, PROPERTIES, PROPERTY_GRACE_PERIOD, PROPERTY_LICENSE_EXPIRE_DATE, PROPERTY_LICENSE_ISSUE_DATE, PROPERTY_LICENSE_NUMBER, PROPERTY_LICENSE_OPTIONS, PROPERTY_LICENSE_TYPE, PROPERTY_NUMBER_COPIES, PROPERTY_PRODUCT, PROPERTY_PRODUCT_EDITION, PROPERTY_PRODUCT_MAJOR_VERSION, PROPERTY_PRODUCT_MINOR_VERSION, PROPERTY_USER_LICENSING_MODEL, TYPE_COMMERCIAL, TYPE_EVALUATION, TYPE_EXTENDED_EVALUATION, USER_LICENSING_FLOATING, USER_LICENSING_FLOATING_LS, USER_LICENSING_NAMED, USER_LICENSING_NAMED_LS, USER_LICENSING_UNCOUNTED, USER_LICENSING_UNKNOWN
 
Constructor Summary
LicenseImpl()
           
 
Method Summary
 java.lang.Object clone()
           
 int getActivationGracePeriod()
          Returns activation grace period (in days) for the license
 java.lang.String getActivationKey()
          Returns activation key of the license
static java.lang.String getActivationTypeStr(int anOptions)
          Utility method to get textual representation of the activation type
 int getCheckoutPeriod()
          Returns period in days the license is allowed to work offline after checkout without need to obtain/renew lock from the Licensing Server (applicable for USER_LICENSING_NAMED_LS model only)
 int getCPULimit()
          Returns CPU/Cores limit
 int getIntProperty(java.lang.String aPropertyName, int aDefault)
          Utility method to get integer license property
 int getLicenseKind()
          Returns kind of a license
 java.lang.String getLicenseLocation()
          Returns location of the license
 int getLicenseState()
          Returns the state of the license
 java.lang.String getLicenseText()
          Returns the license agreement text.
static int getLicenseType(java.lang.String aLicenseType)
          Utility method to get license type value based on its textual representation
static java.lang.String getLicenseTypeStr(int aLicenseType)
          Utility method to get textual representation of the license type
 java.lang.String getLicensingServerAddress()
          Returns address of Licensing Server in form of IP address or domain name.
 int getLockGracePeriod()
          Returns lock grace period (in days) for the license
 int getLockPeriod()
          Returns period in days the license must retain lock to a particular user (applicable for USER_LICENSING_NAMED_LS model only)
 long getLongProperty(java.lang.String aPropertyName, long aDefault)
          Utility method to get long license property
 long getMemoryLimit()
          Returns memory limit in bytes
 int getPrevLicenseMajorVersion()
          Returns major version of previous license required for the Upgrade kind of license
 int getPrevLicenseMinorVersion()
          Returns minor version of previous license required for the Upgrade kind of license
 java.util.List<java.lang.String> getPrevLicenseProductEditions()
          Returns product editions of previous license required for Upgrade kind of license
 java.util.Collection getProductFeatureNames()
          Returns product features' identifiers contained in the license.
 java.util.HashMap getProductFeaturesMap()
          Returns product features map.
 java.util.HashMap getProperties()
          Returns license properties
 java.lang.String getProperty(java.lang.String aName, java.lang.String aDefault)
          Gets license property by its name
 java.util.Collection getPropertyNames()
          Returns the names of the properties contained in the license
 java.lang.String getSerialNumber()
          Returns serial number for the license
 int getUsageGracePeriod()
          Returns usage grace period (in usages) for the license
 int getUsageLimit()
          Returns usage limit for the license
static java.lang.String getUserLicensingModelStr(int aModel)
          Utility method to get textual representation of user licensing model
 boolean isProductFeatureInLicense(java.lang.String aFeature)
          Checks whether certain product feature (functionality) is included into the license.
 boolean isProductFeatureSupported(java.lang.String aFeature)
          Checks whether certain product feature (functionality) is supported (allowed to be used) by the license.
 boolean isProductFeatureSupported(java.lang.String aFeature, int anIndex)
          Checks whether specified feature is supported for the given license type and state combination.
 void putIntProperty(java.lang.String aPropertyName, int aValue)
          Puts integer property to the license
 void putLongProperty(java.lang.String aPropertyName, long aValue)
          Puts long property to the license
 void putProperty(java.lang.String aName, java.lang.String aValue)
          Puts a property to the license
 void setActivationGracePeriod(int aValue)
          Specifies grace period for activation
 void setActivationKey(java.lang.String anActivationKey)
          Specifies activation key
 void setCheckoutPeriod(int aPeriod)
           
 void setCPULimit(int aLimit)
           
 void setLicenseKind(int aLicenseKind)
           
 void setLicenseLocation(java.lang.String aLicenseLocation)
          Specifies license location
 void setLicenseState(int aLicenseState)
          Specifies license state as one of STATE_ constants
 void setLicenseText(java.lang.String aLicenseText)
          Specifies the license agreement text.
 void setLicensingServerAddress(java.lang.String aValue)
          Specifies the address of the Licensing Server that must be used to acquire license lock for this license
 void setLockGracePeriod(int aValue)
          Specifies grace period for the license lock
 void setLockPeriod(int aPeriod)
           
 void setMemoryLimit(long aLimit)
           
 void setPrevLicenseMajorVersion(int aMajorVersion)
           
 void setPrevLicenseMinorVersion(int aMinorVersion)
           
 void setPrevLicenseProductEditions(java.util.List<java.lang.String> aPrevLicenseProductEditions)
           
 void setProductFeatureSupported(java.lang.String aFeature, boolean aValue)
          Deprecated. since 1.2 use setProductFeatureSupported(aFeature, anIndex, aValue) instead
 void setProductFeatureSupported(java.lang.String aFeature, int aCase, boolean aValue)
          Specifies that product feature is supported for particular case
 int smartGetUserLicensingModel()
          Helper method for computing the user licensing model value for pre 3.0 licenses
static int smartGetUserLicensingModel(License aLicense)
          Helper method for computing the user licensing model value for pre 3.0 licenses
 java.lang.String toString()
           
 
Methods inherited from class com.jp.protection.pub.LicenseBaseImpl
getGracePeriod, getLicenseExpireDate, getLicenseIssueDate, getLicenseNumber, getLicenseOptions, getLicenseType, getNumberCopies, getProduct, getProductEdition, getProductMajorVersion, getProductMinorVersion, getUserLicensingModel, setGracePeriod, setLicenseExpireDate, setLicenseIssueDate, setLicenseNumber, setLicenseOptions, setLicenseType, setNumberCopies, setProduct, setProductEdition, setProductMajorVersion, setProductMinorVersion, setUserLicensingModel
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jp.protection.pub.LicenseBase
getGracePeriod, getLicenseExpireDate, getLicenseIssueDate, getLicenseNumber, getLicenseOptions, getLicenseType, getNumberCopies, getProduct, getProductEdition, getProductMajorVersion, getProductMinorVersion, getUserLicensingModel
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

fLicenseState

protected int fLicenseState

fLicenseText

protected java.lang.String fLicenseText

fProductFeaturesMap

protected java.util.HashMap fProductFeaturesMap

fLicenseLocation

protected java.lang.String fLicenseLocation

fProperties

protected java.util.HashMap fProperties

DATE_FORMAT

protected static final java.text.DateFormat DATE_FORMAT

TYPE_STR_COMMERCIAL

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

TYPE_STR_EVALUATION

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

TYPE_STR_EXTENDED_EVALUATION

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

USER_LICENSING_UNKNOWN_STR

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

USER_LICENSING_UNCOUNTED_STR

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

USER_LICENSING_FLOATING_STR

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

USER_LICENSING_NAMED_STR

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

USER_LICENSING_FLOATING_LS_STR

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

USER_LICENSING_NAMED_LS_STR

public static final java.lang.String USER_LICENSING_NAMED_LS_STR
See Also:
Constant Field Values
Constructor Detail

LicenseImpl

public LicenseImpl()
Method Detail

getLicenseLocation

public java.lang.String getLicenseLocation()
Description copied from interface: License
Returns location of the license

Specified by:
getLicenseLocation in interface License
Returns:
location of the license

setLicenseLocation

public void setLicenseLocation(java.lang.String aLicenseLocation)
Specifies license location

Parameters:
aLicenseLocation - license location

setLicenseText

public void setLicenseText(java.lang.String aLicenseText)
Specifies the license agreement text.

Parameters:
aLicenseText - license agreement text

getProductFeaturesMap

public java.util.HashMap getProductFeaturesMap()
Returns product features map. In this map keys are feature names; values depend on version:

Returns:
product features map

getLicenseState

public int getLicenseState()
Description copied from interface: License
Returns the state of the license

Specified by:
getLicenseState in interface License
Returns:
the state of the license; can be one of the STATE_constants

setLicenseState

public void setLicenseState(int aLicenseState)
Specifies license state as one of STATE_ constants

Parameters:
aLicenseState - license state to set

getLicenseText

public java.lang.String getLicenseText()
Description copied from interface: License
Returns the license agreement text. Typically this text can be shown in the appropriate license dialog where the user should read and accept it. In most of the cases license text is provided by the application but having one in the license allows superceding it. This allows providing custom licenses without need to recompile application.

Specified by:
getLicenseText in interface License
Returns:
text of the license agreement.

isProductFeatureInLicense

public boolean isProductFeatureInLicense(java.lang.String aFeature)
Description copied from interface: License
Checks whether certain product feature (functionality) is included into the license.

Specified by:
isProductFeatureInLicense in interface License
Parameters:
aFeature - identifier of a feature to check
Returns:
true if feature is included into the license, false otherwise.

setProductFeatureSupported

public void setProductFeatureSupported(java.lang.String aFeature,
                                       boolean aValue)
Deprecated. since 1.2 use setProductFeatureSupported(aFeature, anIndex, aValue) instead

Specifies that product feature is supported

Parameters:
aFeature - product feature identifier
aValue - true if product feature should be supported; false otherwise

getProductFeatureNames

public java.util.Collection getProductFeatureNames()
Description copied from interface: License
Returns product features' identifiers contained in the license.

Specified by:
getProductFeatureNames in interface License
Returns:
an array that holds product features contained in the license

isProductFeatureSupported

public boolean isProductFeatureSupported(java.lang.String aFeature)
Description copied from interface: License
Checks whether certain product feature (functionality) is supported (allowed to be used) by the license. It is equivalent to a call to the isProductFeatureSupported(aFeature, CASE_ENABLED) for Standard Edition or isProductFeatureSupported(aFeature, CASE_COMMERCIAL_ENABLED) for Professional Edition.

Specified by:
isProductFeatureSupported in interface License
Parameters:
aFeature - identifier of a feature to check
Returns:
true if feature is supported by the license, false otherwise. If feature is not found in the license it is considered to be unsupported.

isProductFeatureSupported

public boolean isProductFeatureSupported(java.lang.String aFeature,
                                         int anIndex)
Description copied from interface: License
Checks whether specified feature is supported for the given license type and state combination.

Specified by:
isProductFeatureSupported in interface License
Parameters:
aFeature - identifier of a feature to check
anIndex - defines license type and state combination to check a feature against to. Should be one of the CASE_ constants.
Returns:
true if product feature is supported, false otherwise

setProductFeatureSupported

public void setProductFeatureSupported(java.lang.String aFeature,
                                       int aCase,
                                       boolean aValue)
Specifies that product feature is supported for particular case

Parameters:
aFeature - product feature identifier
aCase - identifies case (one of CASE_ constants) feature should be supported for
aValue - true if product feature should be supported; false otherwise

getProperties

public java.util.HashMap getProperties()
Returns license properties

Returns:
license properties

getProperty

public java.lang.String getProperty(java.lang.String aName,
                                    java.lang.String aDefault)
Description copied from interface: License
Gets license property by its name

Specified by:
getProperty in interface License
Parameters:
aName - property name
aDefault - default property value used if property is not found in the license
Returns:
property value or the aDefault value if property is not found in the license

putProperty

public void putProperty(java.lang.String aName,
                        java.lang.String aValue)
Puts a property to the license

Parameters:
aName - property name
aValue - property value

getPropertyNames

public java.util.Collection getPropertyNames()
Description copied from interface: License
Returns the names of the properties contained in the license

Specified by:
getPropertyNames in interface License
Returns:
names of the properties contained in the license

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getActivationTypeStr

public static java.lang.String getActivationTypeStr(int anOptions)
Utility method to get textual representation of the activation type

Parameters:
anOptions - options to the textual representation for
Returns:
textual representation of the activation type

getLicenseTypeStr

public static java.lang.String getLicenseTypeStr(int aLicenseType)
Utility method to get textual representation of the license type

Parameters:
aLicenseType - license type value
Returns:
textual representation of the license type

getLicenseType

public static int getLicenseType(java.lang.String aLicenseType)
Utility method to get license type value based on its textual representation

Parameters:
aLicenseType - textual representation of license type
Returns:
license type value

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getIntProperty

public int getIntProperty(java.lang.String aPropertyName,
                          int aDefault)
Utility method to get integer license property

Parameters:
aPropertyName - property name
aDefault - default property value used if property is not found in the license
Returns:
integer license property

putIntProperty

public void putIntProperty(java.lang.String aPropertyName,
                           int aValue)
Puts integer property to the license

Parameters:
aPropertyName - property name
aValue - property value

getLicensingServerAddress

public java.lang.String getLicensingServerAddress()
Description copied from interface: License
Returns address of Licensing Server in form of IP address or domain name.

Specified by:
getLicensingServerAddress in interface License
Returns:
address of Licensing Server

setLicensingServerAddress

public void setLicensingServerAddress(java.lang.String aValue)
Specifies the address of the Licensing Server that must be used to acquire license lock for this license

Parameters:
aValue - address of the Licensing Server
Since:
3.0

getLockGracePeriod

public int getLockGracePeriod()
Description copied from interface: License
Returns lock grace period (in days) for the license

Specified by:
getLockGracePeriod in interface License
Returns:
lock grace period value or NO_GRACE_PERIOD if no grace period is allowed

setLockGracePeriod

public void setLockGracePeriod(int aValue)
Specifies grace period for the license lock

Parameters:
aValue - grace period in days
Since:
3.0

getActivationGracePeriod

public int getActivationGracePeriod()
Description copied from interface: License
Returns activation grace period (in days) for the license

Specified by:
getActivationGracePeriod in interface License
Returns:
activation grace period value or NO_GRACE_PERIOD if no grace period is allowed

setActivationGracePeriod

public void setActivationGracePeriod(int aValue)
Specifies grace period for activation

Parameters:
aValue - grace period in days

getActivationKey

public java.lang.String getActivationKey()
Description copied from interface: License
Returns activation key of the license

Specified by:
getActivationKey in interface License
Returns:
activation key

setActivationKey

public void setActivationKey(java.lang.String anActivationKey)
Specifies activation key

Parameters:
anActivationKey - activation key

getSerialNumber

public java.lang.String getSerialNumber()
Description copied from interface: License
Returns serial number for the license

Specified by:
getSerialNumber in interface License
Returns:
serial number

getUsageGracePeriod

public int getUsageGracePeriod()
Description copied from interface: License
Returns usage grace period (in usages) for the license

Specified by:
getUsageGracePeriod in interface License
Returns:
usage grace period value or NO_GRACE_PERIOD if no grace period is allowed

getUsageLimit

public int getUsageLimit()
Description copied from interface: License
Returns usage limit for the license

Specified by:
getUsageLimit in interface License
Returns:
usage limit

smartGetUserLicensingModel

public int smartGetUserLicensingModel()
Helper method for computing the user licensing model value for pre 3.0 licenses

Returns:
user licensing model value
Since:
3.0

smartGetUserLicensingModel

public static int smartGetUserLicensingModel(License aLicense)
Helper method for computing the user licensing model value for pre 3.0 licenses

Parameters:
aLicense - license to compute user licensing model for
Returns:
user licensing model value
Since:
3.0

getUserLicensingModelStr

public static java.lang.String getUserLicensingModelStr(int aModel)
Utility method to get textual representation of user licensing model

Parameters:
aModel - user licensing model
Returns:
textual representation of user licensing model

getLongProperty

public long getLongProperty(java.lang.String aPropertyName,
                            long aDefault)
Utility method to get long license property

Parameters:
aPropertyName - property name
aDefault - default property value used if property is not found in the license
Returns:
long license property
Since:
v5.0

putLongProperty

public void putLongProperty(java.lang.String aPropertyName,
                            long aValue)
Puts long property to the license

Parameters:
aPropertyName - property name
aValue - property value

getCPULimit

public int getCPULimit()
Description copied from interface: License
Returns CPU/Cores limit

Specified by:
getCPULimit in interface License
Returns:
CPU/Cores limit

setCPULimit

public void setCPULimit(int aLimit)

getMemoryLimit

public long getMemoryLimit()
Description copied from interface: License
Returns memory limit in bytes

Specified by:
getMemoryLimit in interface License
Returns:
memory limit in bytes

setMemoryLimit

public void setMemoryLimit(long aLimit)

getLockPeriod

public int getLockPeriod()
Description copied from interface: License
Returns period in days the license must retain lock to a particular user (applicable for USER_LICENSING_NAMED_LS model only)

Specified by:
getLockPeriod in interface License
Returns:
period in days

setLockPeriod

public void setLockPeriod(int aPeriod)

getCheckoutPeriod

public int getCheckoutPeriod()
Description copied from interface: License
Returns period in days the license is allowed to work offline after checkout without need to obtain/renew lock from the Licensing Server (applicable for USER_LICENSING_NAMED_LS model only)

Specified by:
getCheckoutPeriod in interface License
Returns:
period in days; 0 if checkout is not allowed

setCheckoutPeriod

public void setCheckoutPeriod(int aPeriod)

getLicenseKind

public int getLicenseKind()
Description copied from interface: License
Returns kind of a license

Specified by:
getLicenseKind in interface License
Returns:
license kind as one of KIND_ constants

setLicenseKind

public void setLicenseKind(int aLicenseKind)

getPrevLicenseMajorVersion

public int getPrevLicenseMajorVersion()
Description copied from interface: License
Returns major version of previous license required for the Upgrade kind of license

Specified by:
getPrevLicenseMajorVersion in interface License
Returns:
major version

setPrevLicenseMajorVersion

public void setPrevLicenseMajorVersion(int aMajorVersion)

getPrevLicenseMinorVersion

public int getPrevLicenseMinorVersion()
Description copied from interface: License
Returns minor version of previous license required for the Upgrade kind of license

Specified by:
getPrevLicenseMinorVersion in interface License
Returns:
minor version

setPrevLicenseMinorVersion

public void setPrevLicenseMinorVersion(int aMinorVersion)

getPrevLicenseProductEditions

public java.util.List<java.lang.String> getPrevLicenseProductEditions()
Description copied from interface: License
Returns product editions of previous license required for Upgrade kind of license

Specified by:
getPrevLicenseProductEditions in interface License
Returns:
minor version

setPrevLicenseProductEditions

public void setPrevLicenseProductEditions(java.util.List<java.lang.String> aPrevLicenseProductEditions)