com.jp.protection.pub.pro
Class LicensingServiceSupport

java.lang.Object
  extended by com.jp.protection.pub.LicenseAdapter
      extended by com.jp.protection.pub.pro.LicensingServiceSupport
All Implemented Interfaces:
LicenseHostListener, LicenseListener, LicenseReaderListener, LicenseReaderListenerExt, java.util.EventListener

public class LicensingServiceSupport
extends LicenseAdapter

Utility class that encapsulates all the code required to connect and work with the Licensing Server. An instance of this class is used by the Licensing Assistant and the License Host providing support for getting licenses and handling of concurrent user models.

Since:
3.0

Field Summary
protected  boolean fAcquireMACAddress
           
protected  LicensingServiceResult.CheckoutResult fCheckoutLicenseResult
           
protected  LicensingServiceResult fConfirmLockResult
           
protected  LicenseHostPro fLicenseHost
           
protected  LicensePass fLicensePass
           
protected  java.lang.String fLicensingServerAddress
           
protected  LicensingService fLicensingService
           
protected  LicensingServiceProvider fLicensingServiceProvider
           
protected  LicensingServiceProviderListener fLicensingServiceProviderListener
           
protected  LicensingServiceResult fLockResult
           
protected  LicensingServiceResult fObtainLicenseResult
           
protected  java.util.prefs.Preferences fPreferences
           
protected  java.lang.String fProviderName
           
protected  dev.net.NetworkResourceStatus fServerStatus
           
protected  java.lang.Thread fShutdownHook
           
protected  LicensingServiceResult fUnlockLicenseResult
           
 
Fields inherited from class com.jp.protection.pub.LicenseAdapter
fVerbose
 
Constructor Summary
LicensingServiceSupport(LicenseHostPro aLicenseHost)
          Creates a new instance of given License Host
 
Method Summary
protected  void applyHttpProxy()
           
 boolean canCheckoutLicense()
          Checks whether license can be checked out from the Licensing Server
 LicensingServiceResult canLockLicense()
          Query the Licensing Server to check whether license lock can be acquired
 boolean canTerminateLicensePass()
          Tests whether License Pass can be terminated
 boolean checkoutLicense()
          Check outs license for offline use
protected  boolean checkServerStatus()
           
static LicensingServiceResult.CheckoutResult createCheckoutResult(java.lang.Exception ex)
          Creates result object for a given exception
 LicensingService createLicensingService(LicensingServiceProvider aLicensingServiceProvider)
          Creates a new instance of Licensing Service using specified provider
 LicensingServiceProvider createLicensingServiceProvider(java.lang.String aLicensingServerAddress)
          Creates a new instance Licensing Service Provider for the given address
static LicenseData.Request createRequest(ProductInfo aProductInfo)
          Creates request for given product information
static LicensingServiceResult createResult(dev.net.NetworkResourceStatus aServerStatus)
          Creates result object for a given server status object
static LicensingServiceResult createResult(java.lang.RuntimeException ex)
          Creates result object for given exception
protected  void error(java.lang.String aMessage)
           
protected  void error(java.lang.Throwable ex)
           
 LicensingServiceResult.CheckoutResult getCheckoutLicenseResult()
           
 LicensingServiceResult getConfirmLockResult()
          Returns result of last license lock confirm operation
 LicensePass getLicensePass()
           
protected  java.io.File getLicensePassFile()
           
 java.lang.String getLicensingServerAddress()
          Returns address of the Licensing Server used when no corresponding address is specified for the license
 LicensingService getLicensingService()
          Returns cached Licensing Service instance
 LicensingService getLicensingService(boolean aForceCreate)
          Returns cached Licensing Service instance
protected  LicensingServiceProvider getLicensingServiceProvider()
           
 LicensingServiceResult getLockResult()
          Returns result of last license lock operation
 byte[] getObtainedLicenseBytes()
          Returns license bytes obtained during last obtainLicense(...) call
 LicensingServiceResult getObtainLicenseResult()
          Returns result of last obtain license operation
 java.util.prefs.Preferences getPreferences()
           
 java.lang.String getProviderName()
          Returns name of the Licensing Service Provider to use
 dev.net.NetworkResourceStatus getServerStatus()
           
 java.net.URL getServerStatusURL()
           
 LicensingServiceResult getUnlockLicenseResult()
          Return result of last unlock license operation
static java.lang.String getUserMessage(java.lang.Throwable ex)
          Compose message can be shown to the end user for the given exception
 boolean hasLicensingServiceProvider()
          Checks whether Licensing Service Provider is already created
 boolean isAcquireMACAddress()
          Returns whether MAC address(es) of the network card(s) must be acquired during composing requests for the Licensing Server
protected  boolean isHttpProxyChanged()
           
 boolean isLicensingServerAddressKnown()
          Returns if Licensing Server address is specified for the license
 boolean isLockExpired()
          Returns whether license lock is already expired.
 boolean isLockOK()
          Returns whether license lock is OK: license is locked and lock is neither expired nor revoked.
 boolean isLockRevoked()
          Returns whether license lock revocation has been requested by the administrator.
 void licenseAboutToRead(LicenseReader aSource, java.lang.String aProductID)
          Releases all the resources when new license is about to read.
 boolean lockLicense(boolean isForceLock)
          Acquires license lock using the Licensing Server.
 boolean obtainLicense(LicensingService aLicensingService, ProductInfo aProductInfo)
          Obtains a license identified by the product information from the Licensing Server.
 boolean obtainLicense(LicensingService aLicensingService, ProductInfo aProductInfo, java.util.Map anAttributes)
          Obtains a license identified by the product information from the Licensing Server.
 boolean obtainLicense(java.lang.String aServerAddress, ProductInfo aProductInfo)
          Obtains a license identified by the product information from the Licensing Server.
 void release()
          Releases all the acquired resources including Licensing Service provider, Licensing Service services and license locks
 void release(boolean isShutdown)
          Releases all the acquired resources including Licensing Service provider, Licensing Service services and license locks
 void setAcquireMACAddress(boolean aAcquireMACAddress)
          Specifies that MAC address(es) of the network card(s) must be acquired during composing requests for the Licensing Server
 void setLicensingServerAddress(java.lang.String aLicensingServerAddress)
          Specifies address of the Licensing Server should be used when no corresponding address is specified for the license.
 void setLockResult(LicensingServiceResult aLockResult)
          Specifies result of last license lock operation
 void setPreferences(java.util.prefs.Preferences aPreferences)
           
 void setProviderName(java.lang.String aProviderName)
          Specifies the name of the Licensing Service Provider to use
 void setServerStatusURL(java.net.URL anURL)
           
 boolean terminateLicensePass()
          Terminate ability to use a License offline by removing corresponding License Pass
 boolean unlockLicense()
          Releases license lock
 
Methods inherited from class com.jp.protection.pub.LicenseAdapter
featureChecked, isVerbose, licenseAboutToExpire, licenseAccepted, licenseAvailable, licenseCorrupted, licenseExpired, licenseInvalid, licenseLockExpired, licenseLockRevoked, licenseLockViolation, licenseMissing, licenseNeedActivation, licenseNeedLock, licenseNotActivated, licenseNotLocked, licenseOk, licenseRemoved, licenseUpdated, licenseUseLimitAboutReach, message, numberCopiesViolation, setVerbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fLicenseHost

protected LicenseHostPro fLicenseHost

fProviderName

protected java.lang.String fProviderName

fLicensingServiceProvider

protected LicensingServiceProvider fLicensingServiceProvider

fLicensingService

protected LicensingService fLicensingService

fShutdownHook

protected java.lang.Thread fShutdownHook

fLicensingServerAddress

protected java.lang.String fLicensingServerAddress

fLicensingServiceProviderListener

protected LicensingServiceProviderListener fLicensingServiceProviderListener

fObtainLicenseResult

protected LicensingServiceResult fObtainLicenseResult

fLockResult

protected LicensingServiceResult fLockResult

fConfirmLockResult

protected LicensingServiceResult fConfirmLockResult

fUnlockLicenseResult

protected LicensingServiceResult fUnlockLicenseResult

fCheckoutLicenseResult

protected LicensingServiceResult.CheckoutResult fCheckoutLicenseResult

fLicensePass

protected LicensePass fLicensePass

fAcquireMACAddress

protected boolean fAcquireMACAddress

fPreferences

protected java.util.prefs.Preferences fPreferences

fServerStatus

protected dev.net.NetworkResourceStatus fServerStatus
Constructor Detail

LicensingServiceSupport

public LicensingServiceSupport(LicenseHostPro aLicenseHost)
Creates a new instance of given License Host

Parameters:
aLicenseHost - License Host
Method Detail

licenseAboutToRead

public void licenseAboutToRead(LicenseReader aSource,
                               java.lang.String aProductID)
Releases all the resources when new license is about to read.

Specified by:
licenseAboutToRead in interface LicenseReaderListener
Overrides:
licenseAboutToRead in class LicenseAdapter
Parameters:
aSource - the license reader.
aProductID - ID of the product this license is issued for.

getProviderName

public java.lang.String getProviderName()
Returns name of the Licensing Service Provider to use

Returns:
name of the Licensing Service Provider

setProviderName

public void setProviderName(java.lang.String aProviderName)
Specifies the name of the Licensing Service Provider to use

Parameters:
aProviderName - name of the Licensing Service Provider

getLicensingServerAddress

public java.lang.String getLicensingServerAddress()
Returns address of the Licensing Server used when no corresponding address is specified for the license

Returns:
address of the Licensing Server

setLicensingServerAddress

public void setLicensingServerAddress(java.lang.String aLicensingServerAddress)
Specifies address of the Licensing Server should be used when no corresponding address is specified for the license.

Parameters:
aLicensingServerAddress - address of the Licensing Server

isLicensingServerAddressKnown

public boolean isLicensingServerAddressKnown()
Returns if Licensing Server address is specified for the license

Returns:
true if Licensing Server address is specified for the license; false otherwise

hasLicensingServiceProvider

public boolean hasLicensingServiceProvider()
Checks whether Licensing Service Provider is already created

Returns:
true if Licensing Service Provider is already created; false otherwise

createLicensingServiceProvider

public LicensingServiceProvider createLicensingServiceProvider(java.lang.String aLicensingServerAddress)
Creates a new instance Licensing Service Provider for the given address

Parameters:
aLicensingServerAddress - address of the Licensing Server
Returns:
a new instance Licensing Service Provider

createLicensingService

public LicensingService createLicensingService(LicensingServiceProvider aLicensingServiceProvider)
Creates a new instance of Licensing Service using specified provider

Parameters:
aLicensingServiceProvider - Licensing Service Provider used to create Licensing Service
Returns:
a new instance of Licensing Service

getLicensingServiceProvider

protected LicensingServiceProvider getLicensingServiceProvider()

getLockResult

public LicensingServiceResult getLockResult()
Returns result of last license lock operation

Returns:
result of last license lock operation

getConfirmLockResult

public LicensingServiceResult getConfirmLockResult()
Returns result of last license lock confirm operation

Returns:
result of last license lock confirm operation

getObtainLicenseResult

public LicensingServiceResult getObtainLicenseResult()
Returns result of last obtain license operation

Returns:
result of last obtain license operation

setLockResult

public void setLockResult(LicensingServiceResult aLockResult)
Specifies result of last license lock operation

Parameters:
aLockResult - result of last license lock operation

createRequest

public static LicenseData.Request createRequest(ProductInfo aProductInfo)
Creates request for given product information

Parameters:
aProductInfo - product information
Returns:
request

lockLicense

public boolean lockLicense(boolean isForceLock)
Acquires license lock using the Licensing Server.

Parameters:
isForceLock - specifies whether license lock should be re-acquired.
Returns:
true if license lock is acquired; false otherwise. Full result of the operation can be obtained by the getLockResult() call.

obtainLicense

public boolean obtainLicense(java.lang.String aServerAddress,
                             ProductInfo aProductInfo)
Obtains a license identified by the product information from the Licensing Server.

Parameters:
aServerAddress - Licensing Server address to obtain a license from
aProductInfo - product information identifies a license to obtain
Returns:
true if license is obtained; false otherwise. Full result of the operation can be obtained by a getObtainLicenseResult() call and license bytes for the license can be got by a getObtainedLicenseBytes() call.

obtainLicense

public boolean obtainLicense(LicensingService aLicensingService,
                             ProductInfo aProductInfo)
Obtains a license identified by the product information from the Licensing Server.

Parameters:
aLicensingService - instance of the Licensing Service to use
aProductInfo - product information identifies a license to obtain
Returns:
true if license is obtained; false otherwise. Full result of the operation can be obtained by a getObtainLicenseResult() call and license bytes for the license can be got by a getObtainedLicenseBytes() call.

obtainLicense

public boolean obtainLicense(LicensingService aLicensingService,
                             ProductInfo aProductInfo,
                             java.util.Map anAttributes)
Obtains a license identified by the product information from the Licensing Server.

Parameters:
aLicensingService - instance of the Licensing Service to use
aProductInfo - product information identifies a license to obtain
anAttributes - attributes to pass to Licensing Server
Returns:
true if license is obtained; false otherwise. Full result of the operation can be obtained by a getObtainLicenseResult() call and license bytes for the license can be got by a getObtainedLicenseBytes() call.

getObtainedLicenseBytes

public byte[] getObtainedLicenseBytes()
Returns license bytes obtained during last obtainLicense(...) call

Returns:
license bytes

createResult

public static LicensingServiceResult createResult(java.lang.RuntimeException ex)
Creates result object for given exception

Parameters:
ex - exception to get result object for
Returns:
result object

canLockLicense

public LicensingServiceResult canLockLicense()
Query the Licensing Server to check whether license lock can be acquired

Returns:
operation result

isLockOK

public boolean isLockOK()
Returns whether license lock is OK: license is locked and lock is neither expired nor revoked.

Returns:
true if license lock is OK; false otherwise.

isLockRevoked

public boolean isLockRevoked()
Returns whether license lock revocation has been requested by the administrator.

Returns:
true if license lock revocation has been requested; false otherwise.

isLockExpired

public boolean isLockExpired()
Returns whether license lock is already expired.

Returns:
true if license lock is already expired; false otherwise.

unlockLicense

public boolean unlockLicense()
Releases license lock

Returns:
true if license lock released; false otherwise. Full result of the operation can be obtained by the getUnlockLicenseResult() call.

getUnlockLicenseResult

public LicensingServiceResult getUnlockLicenseResult()
Return result of last unlock license operation

Returns:
operation result

getCheckoutLicenseResult

public LicensingServiceResult.CheckoutResult getCheckoutLicenseResult()

getLicensePassFile

protected java.io.File getLicensePassFile()

getLicensePass

public LicensePass getLicensePass()

checkoutLicense

public boolean checkoutLicense()
Check outs license for offline use

Returns:
true if license was successfully checked out; false otherwise
Since:
v5.0

createCheckoutResult

public static LicensingServiceResult.CheckoutResult createCheckoutResult(java.lang.Exception ex)
Creates result object for a given exception

Parameters:
ex - exception to get result object for
Returns:
result object
Since:
v5.0

canCheckoutLicense

public boolean canCheckoutLicense()
Checks whether license can be checked out from the Licensing Server

Returns:
true if the license can be checked out from the Licensing Server; false otherwise
Since:
v5.0

terminateLicensePass

public boolean terminateLicensePass()
Terminate ability to use a License offline by removing corresponding License Pass

Returns:
true if License Pass has been terminated; false otherwise
Since:
v5.0

canTerminateLicensePass

public boolean canTerminateLicensePass()
Tests whether License Pass can be terminated

Returns:
true if License can be terminated; false otherwise
Since:
v5.0

isAcquireMACAddress

public boolean isAcquireMACAddress()
Returns whether MAC address(es) of the network card(s) must be acquired during composing requests for the Licensing Server

Returns:
true if MAC address(es) must be acquired; false otherwise

setAcquireMACAddress

public void setAcquireMACAddress(boolean aAcquireMACAddress)
Specifies that MAC address(es) of the network card(s) must be acquired during composing requests for the Licensing Server

Parameters:
aAcquireMACAddress - true if MAC address(es) must be acquired; false otherwise

getLicensingService

public LicensingService getLicensingService()
Returns cached Licensing Service instance

Returns:
cached Licensing Service instance

getLicensingService

public LicensingService getLicensingService(boolean aForceCreate)
Returns cached Licensing Service instance

Parameters:
aForceCreate - specifies that cached instance (if any) must be recreated
Returns:
cached Licensing Service instance

getUserMessage

public static java.lang.String getUserMessage(java.lang.Throwable ex)
Compose message can be shown to the end user for the given exception

Parameters:
ex - exceptions to compose message for
Returns:
message

error

protected void error(java.lang.String aMessage)
Overrides:
error in class LicenseAdapter

error

protected void error(java.lang.Throwable ex)

release

public void release(boolean isShutdown)
Releases all the acquired resources including Licensing Service provider, Licensing Service services and license locks

Parameters:
isShutdown - identifies whether release is called during the application shutdown (exit).

release

public void release()
Releases all the acquired resources including Licensing Service provider, Licensing Service services and license locks


getPreferences

public java.util.prefs.Preferences getPreferences()

setPreferences

public void setPreferences(java.util.prefs.Preferences aPreferences)

isHttpProxyChanged

protected boolean isHttpProxyChanged()

applyHttpProxy

protected void applyHttpProxy()

getServerStatusURL

public java.net.URL getServerStatusURL()

setServerStatusURL

public void setServerStatusURL(java.net.URL anURL)

getServerStatus

public dev.net.NetworkResourceStatus getServerStatus()

checkServerStatus

protected boolean checkServerStatus()

createResult

public static LicensingServiceResult createResult(dev.net.NetworkResourceStatus aServerStatus)
Creates result object for a given server status object

Parameters:
aServerStatus - server status to get result object for
Returns:
result object