com.jp.protection.priv.pro.integration
Class LicensingFacadeExtensionSupport

java.lang.Object
  extended by com.jp.protection.priv.pro.integration.LicensingFacadeExtensionSupport
All Implemented Interfaces:
LicensingFacadeExtension, LicensingFacadePlugin

public abstract class LicensingFacadeExtensionSupport
extends java.lang.Object
implements LicensingFacadeExtension

This class provides basic implementation of the LicensingFacadeExtension interface that can be used to build actual implementations


Field Summary
protected  LocalLicensingFacade fLocalLicensingFacade
           
static java.lang.String MSG_ID_ALREADY_ACTIVATED
           
static java.lang.String MSG_ID_ALREADY_DEACTIVATED
           
static java.lang.String MSG_ID_ALREADY_ISSUED
           
static java.lang.String MSG_ID_NOT_PROPERLY_DEACTIVATED
           
static java.lang.String MSG_ID_NUMBER_COPIES_EXCEEDED
           
(package private) static java.util.ResourceBundle res
           
(package private) static java.lang.String RESOURCE_BUNDLE_NAME
           
 
Constructor Summary
LicensingFacadeExtensionSupport()
           
 
Method Summary
 void acquireConnection()
          Acquires connection (e.g.
 boolean checkActivateLicenseEnabled(LicensingFacadeSession aSession, LicenseBase aLicenseInfo)
          Checks whether it is possible to activate license.
 boolean checkDeactivateLicenseEnabled(LicensingFacadeSession aSession, LicenseBase aLicenseInfo)
          Checks whether it is possible to deactivate license.
 boolean checkGetLicenseEnabled(LicensingFacadeSession aSession, LicenseBase aLicenseInfo)
          Checks whether it is possible to get licenses according to the specified license information.
 void commit()
          Commits changes made during this session
 void commit(LicensingFacadeSession aSession)
          Commits changes made during this session by calling the commit() method
 LicensingFacadeResult deliver(LicensingFacadeSession aSession, int aDeliveryType, License aLicense, dev.entities.Customer aCustomer)
          Delivers license to the customer.
 int getDeliveryType(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer)
          Returns delivery type for the given arguments
protected static java.util.Locale getLocale(java.lang.String aLocale)
           
protected static java.lang.String getLocalizedMessage(java.lang.String aMessageID, LicensingFacadeSession aSession)
           
protected static java.lang.String getLocalizedMessage(java.lang.String aBundleName, java.lang.String aMessageID, java.lang.String aLocale)
           
 LocalLicensingFacade getLocalLicensingFacade()
          Returns local licensing facade this extension is working for
protected  com.jp.protection.utils.ProtectionLogger getLogger()
           
 void init(LocalLicensingFacade aLicensingFacade)
          Initializes plug-in.
abstract  boolean isLicenseAlreadyActivated(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer, java.lang.String anActivationKey, java.lang.StringBuffer aMessage)
          Checks whether requested license is already activated for particular customer.
abstract  boolean isLicenseAlreadyDeactivated(LicensingFacadeSession aSession, LicenseImpl aLicense, java.lang.StringBuffer aMessage)
          Checks whether requested license is already deactivated.
abstract  boolean isLicenseAlreadyIssued(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer, java.lang.StringBuffer aMessage)
          Checks whether requested license is already issued for particular customer.
abstract  void logActivatedLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer, java.lang.String anActivationKey, boolean isSuccess, LicensingFacadeResultBase aResult)
          Logs activated licence.
abstract  void logDeactivatedLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, java.lang.String aDeactivationKey, boolean isSuccess, LicensingFacadeResultBase aResult)
          Logs deactivated licence.
 LicensingFacadeSession login(LicenseBase aLicenseInfo, java.lang.String aLogin, java.lang.String aPassword, java.util.Map anArguments, int anOperation)
          Authenticates and authorizes attempt to get or activate a license.
abstract  void logIssuedLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer, boolean isSuccess, LicensingFacadeResultBase aResult)
          Logs issued licence.
abstract  void logLicenseDelivery(LicensingFacadeSession aSession, int aDeliveryType, License aLicense, dev.entities.Customer aCustomer, LicensingFacadeResult aResult, boolean isSuccess)
          Logs license delivery.
 LicensingFacadeResultBase onActivateLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer, java.lang.String anActivationKey)
          This method allows inclusion into the process of license activation.
 LicensingFacadeResultBase onDeactivateLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, java.lang.String aDeactivationKey, boolean isSuccess)
          This method allows inclusion into the process of license deactivation.
 LicensingFacadeResultBase onGetLicense(LicensingFacadeSession aSession, LicenseImpl aLicense, dev.entities.Customer aCustomer)
          This method allows inclusion into the process of the license generation.
 void releaseConnection()
          Releases connection (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

res

static java.util.ResourceBundle res

RESOURCE_BUNDLE_NAME

static java.lang.String RESOURCE_BUNDLE_NAME

MSG_ID_ALREADY_ACTIVATED

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

MSG_ID_NUMBER_COPIES_EXCEEDED

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

MSG_ID_ALREADY_ISSUED

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

MSG_ID_ALREADY_DEACTIVATED

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

MSG_ID_NOT_PROPERLY_DEACTIVATED

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

fLocalLicensingFacade

protected LocalLicensingFacade fLocalLicensingFacade
Constructor Detail

LicensingFacadeExtensionSupport

public LicensingFacadeExtensionSupport()
Method Detail

getLocalizedMessage

protected static java.lang.String getLocalizedMessage(java.lang.String aMessageID,
                                                      LicensingFacadeSession aSession)

getLocalizedMessage

protected static java.lang.String getLocalizedMessage(java.lang.String aBundleName,
                                                      java.lang.String aMessageID,
                                                      java.lang.String aLocale)

getLocale

protected static java.util.Locale getLocale(java.lang.String aLocale)

getLocalLicensingFacade

public LocalLicensingFacade getLocalLicensingFacade()
Returns local licensing facade this extension is working for

Returns:
local licensing facade

init

public void init(LocalLicensingFacade aLicensingFacade)
Description copied from interface: LicensingFacadePlugin
Initializes plug-in. Local licensing facade calls this methods during the plug-in instantiation

Specified by:
init in interface LicensingFacadePlugin
Parameters:
aLicensingFacade - licensing facade this plug-in will working for

login

public LicensingFacadeSession login(LicenseBase aLicenseInfo,
                                    java.lang.String aLogin,
                                    java.lang.String aPassword,
                                    java.util.Map anArguments,
                                    int anOperation)
Authenticates and authorizes attempt to get or activate a license. Caller credentials (login and password) should be checked to ensure that the caller is known to the the system. License information should be used to ensure that the caller has rights to get or activate certain type of license.

Implementation of the method calls to getLocalLicensingFacade().isLoginEnabled(aLicenseInfo, aLogin, aPassword) to determine whether it's possible to login.

Specified by:
login in interface LicensingFacadeExtension
Parameters:
aLicenseInfo - license information
aLogin - login name
aPassword - password
anArguments - additional arguments can be needed for proper license getting or activation
anOperation - operation as one of LicensingFacadeSession.OPERATION_ constants
Returns:
a session object that by default holds specified login information. Custom implementations can return custom session objects that could carry out any additional information. Returns null if the caller has no rights to get or activate certain type of license.

getLogger

protected com.jp.protection.utils.ProtectionLogger getLogger()

checkGetLicenseEnabled

public boolean checkGetLicenseEnabled(LicensingFacadeSession aSession,
                                      LicenseBase aLicenseInfo)
Checks whether it is possible to get licenses according to the specified license information.

Implementation of the method returns getLocalLicensingFacade().isGetLicenseEnabled(aLicenseInfo) result.

Specified by:
checkGetLicenseEnabled in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as a result of the login() method call.
aLicenseInfo - license information
Returns:
true if it is possible to get license according to the specified license information. false otherwise.

checkActivateLicenseEnabled

public boolean checkActivateLicenseEnabled(LicensingFacadeSession aSession,
                                           LicenseBase aLicenseInfo)
Checks whether it is possible to activate license.

Implementation of the method returns getLocalLicensingFacade().isActivateLicenseEnabled() result.

Specified by:
checkActivateLicenseEnabled in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as the result of the login() method call.
aLicenseInfo - license information
Returns:
true if it is possible to activate license false otherwise.

checkDeactivateLicenseEnabled

public boolean checkDeactivateLicenseEnabled(LicensingFacadeSession aSession,
                                             LicenseBase aLicenseInfo)
Checks whether it is possible to deactivate license.

Implementation of the method returns getLocalLicensingFacade().isDeactivateLicenseEnabled() result.

Specified by:
checkDeactivateLicenseEnabled in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as the result of the login() method call.
aLicenseInfo - license information
Returns:
true if it is possible to deactivate license false otherwise.

deliver

public LicensingFacadeResult deliver(LicensingFacadeSession aSession,
                                     int aDeliveryType,
                                     License aLicense,
                                     dev.entities.Customer aCustomer)
Delivers license to the customer. Method implementation should write license to an array of bytes and assign it to the method's result for the online delivery type. For other delivery types license should be distributed to the user by some other methods (e.g. by sending license as an attachment to the e-mail message). In such case meaningful message should be specified for the method's result to instruct the user on how to find delivered license (e.g. "Please check your mailbox for a license")

Implementation of the method obtains delivery object for specified delivery type and returns delivery.deliver(aLicense, aCustomer) result.

Specified by:
deliver in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as result of the login() method call.
aDeliveryType - type of license delivery. Can be one of the LicensingFacadeResult.DELIVERY_TYPE constants or any custom value known for a particular implementation
aLicense - a license to be delivered
aCustomer - Customer customer information
Returns:
LicensingFacadeResult LicensingFacadeResult instance

logLicenseDelivery

public abstract void logLicenseDelivery(LicensingFacadeSession aSession,
                                        int aDeliveryType,
                                        License aLicense,
                                        dev.entities.Customer aCustomer,
                                        LicensingFacadeResult aResult,
                                        boolean isSuccess)
Logs license delivery. Method implementation can mark already logged record of license getting or activation as "inactive" or simply delete it if delivery is failed. The isSuccess arguments defines whether license delivery is succeeded.

Parameters:
aSession - a session object obtained as result of the login() method call.
aDeliveryType - delivery type
aLicense - an issued license
aCustomer - Customer customer information
aResult - result of license delivery
isSuccess - defines whether delivery is successful

logIssuedLicense

public abstract void logIssuedLicense(LicensingFacadeSession aSession,
                                      LicenseImpl aLicense,
                                      dev.entities.Customer aCustomer,
                                      boolean isSuccess,
                                      LicensingFacadeResultBase aResult)
Logs issued licence. The isSuccess arguments defines whether license is issued or request is rejected.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - an issued license
aCustomer - Customer customer information
isSuccess - defines whether issuing request is successful
aResult - result of license issuing

logActivatedLicense

public abstract void logActivatedLicense(LicensingFacadeSession aSession,
                                         LicenseImpl aLicense,
                                         dev.entities.Customer aCustomer,
                                         java.lang.String anActivationKey,
                                         boolean isSuccess,
                                         LicensingFacadeResultBase aResult)
Logs activated licence. The isSuccess arguments defines whether license is activated or request is rejected.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - an issued license
aCustomer - Customer customer information
anActivationKey - Activation Key placed to the license
isSuccess - defines whether activation request is successful
aResult - result of license activation

logDeactivatedLicense

public abstract void logDeactivatedLicense(LicensingFacadeSession aSession,
                                           LicenseImpl aLicense,
                                           java.lang.String aDeactivationKey,
                                           boolean isSuccess,
                                           LicensingFacadeResultBase aResult)
Logs deactivated licence. The isSuccess arguments defines whether license is deactivated or request is rejected.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - a license to be deactivated
aDeactivationKey - Deactivation Key that holds result of deactivation operation on the customers computer
isSuccess - defines whether deactivation request is successful
aResult - result of license deactivation

isLicenseAlreadyIssued

public abstract boolean isLicenseAlreadyIssued(LicensingFacadeSession aSession,
                                               LicenseImpl aLicense,
                                               dev.entities.Customer aCustomer,
                                               java.lang.StringBuffer aMessage)
Checks whether requested license is already issued for particular customer.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - a license to be issued
aCustomer - Customer customer information
aMessage - string buffer to return a message when license is already issued
Returns:
true if license is already issued; false otherwise

isLicenseAlreadyActivated

public abstract boolean isLicenseAlreadyActivated(LicensingFacadeSession aSession,
                                                  LicenseImpl aLicense,
                                                  dev.entities.Customer aCustomer,
                                                  java.lang.String anActivationKey,
                                                  java.lang.StringBuffer aMessage)
Checks whether requested license is already activated for particular customer.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - a license to be activated
aCustomer - Customer customer information
anActivationKey - Activation Key
aMessage - string buffer to return a message when license is already activated
Returns:
true if license is already activated; false otherwise

onActivateLicense

public LicensingFacadeResultBase onActivateLicense(LicensingFacadeSession aSession,
                                                   LicenseImpl aLicense,
                                                   dev.entities.Customer aCustomer,
                                                   java.lang.String anActivationKey)
Description copied from interface: LicensingFacadeExtension
This method allows inclusion into the process of license activation. Implementation of the method can:

Specified by:
onActivateLicense in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as result of login() method call.
aLicense - a license to be activated
aCustomer - customer information
anActivationKey - activation key
Returns:
an LicensingFacadeResultBase instance

onGetLicense

public LicensingFacadeResultBase onGetLicense(LicensingFacadeSession aSession,
                                              LicenseImpl aLicense,
                                              dev.entities.Customer aCustomer)
Description copied from interface: LicensingFacadeExtension
This method allows inclusion into the process of the license generation. Implementation of the method can:

Specified by:
onGetLicense in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as result of login() method call.
aLicense - a license to be generated
aCustomer - customer information
Returns:
an LicensingFacadeResultBase instance

getDeliveryType

public int getDeliveryType(LicensingFacadeSession aSession,
                           LicenseImpl aLicense,
                           dev.entities.Customer aCustomer)
Returns delivery type for the given arguments

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - a license to be issued
aCustomer - Customer customer information
Returns:
delivery type

isLicenseAlreadyDeactivated

public abstract boolean isLicenseAlreadyDeactivated(LicensingFacadeSession aSession,
                                                    LicenseImpl aLicense,
                                                    java.lang.StringBuffer aMessage)
Checks whether requested license is already deactivated.

Parameters:
aSession - a session object obtained as result of the login() method call.
aLicense - a license to be deactivated
aMessage - string buffer to return a message when license is already issued
Returns:
true if license is already deactivated; false otherwise

onDeactivateLicense

public LicensingFacadeResultBase onDeactivateLicense(LicensingFacadeSession aSession,
                                                     LicenseImpl aLicense,
                                                     java.lang.String aDeactivationKey,
                                                     boolean isSuccess)
Description copied from interface: LicensingFacadeExtension
This method allows inclusion into the process of license deactivation. Implementation of the method should take care about making proper steps to remove previous activation records to allow further license activation on another computer

Specified by:
onDeactivateLicense in interface LicensingFacadeExtension
Parameters:
aSession - a session object obtained as result of login() method call.
aLicense - a license to be deactivated
aDeactivationKey - deactivation key
isSuccess - specifies whether license has been actually deactivated on the client side
Returns:
an LicensingFacadeResultBase instance

acquireConnection

public void acquireConnection()
Acquires connection (e.g. gets JDBC one from the pool) to provide communication with some persistent storage


releaseConnection

public void releaseConnection()
Releases connection (e.g. returns JDBC one to the pool) used to provide communication with some persistent storage


commit

public void commit(LicensingFacadeSession aSession)
Commits changes made during this session by calling the commit() method

Parameters:
aSession - a session object obtained as result of the login() method call.

commit

public void commit()
Commits changes made during this session