com.jp.protection.priv
Class LicenseReaderFacade

java.lang.Object
  extended by com.jp.protection.priv.LicenseReaderFacade
All Implemented Interfaces:
LicenseReaderListener, java.util.EventListener

public class LicenseReaderFacade
extends java.lang.Object
implements LicenseReaderListener

This class represents a "facade" that significantly simplifies licenses reading process


Field Summary
protected  ProductLicenseReader fLicenseReader
           
protected  ProductsStorage fProductsStorage
           
 
Constructor Summary
LicenseReaderFacade(java.io.File aProductsStorageFile)
          Creates a new instance of the LicenseReaderFacade and loads a product storage from the specified file
LicenseReaderFacade(java.io.InputStream aProductsStorageInputStream)
          Creates a new instance of the LicenseReaderFacade and loads a product storage from the specified stream
LicenseReaderFacade(ProductsStorage aProductsStorage)
          Creates a new instance of the LicenseReaderFacade and uses shared and already loaded product storage
 
Method Summary
 void addLicenseReaderListener(LicenseReaderListener l)
          Adds license reader listener.
 boolean isSkipEncryption()
          Checks whether license encryption process should be skipped.
 boolean isVerbose()
          Checks whether facade runs in verbose mode.
 void licenseAboutToRead(LicenseReader aSource, java.lang.String aProductID)
          License reader calls this method to notify listener that the license is about to be read and specifies a known ID of the product this license is issued for.
 void licenseAvailable(LicenseReader aSource, java.lang.String aLicenseLocation)
          License reader calls this method to notify listener that the license is successfully read and available for use.
 void licenseCorrupted(LicenseReader aSource, java.lang.String aLicenseLocation)
          License reader calls this method to notify listener that the license is corrupted and therefore can not be read.
 void licenseMissing(LicenseReader aSource, java.lang.String aLicenseLocation)
          License reader calls this method to notify listener when the license is not found neither in the resource folder nor in the file system.
 License readLicense(byte[] aLicenseBytes)
           
 License readLicense(java.io.File aFile)
           
 License readLicense(java.io.InputStream anInputStream, java.lang.String aLicenseLocation)
           
 void removeLicenseReaderListener(LicenseReaderListener l)
          Removes license reader listener.
 void setSkipEncryption(boolean aSkipEncryption)
          Specifies that the license encryption process should be skipped.
 void setVerbose(boolean aVerbose)
          Specifies that facade should run in verbose mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fLicenseReader

protected ProductLicenseReader fLicenseReader

fProductsStorage

protected ProductsStorage fProductsStorage
Constructor Detail

LicenseReaderFacade

public LicenseReaderFacade(java.io.InputStream aProductsStorageInputStream)
                    throws java.io.IOException
Creates a new instance of the LicenseReaderFacade and loads a product storage from the specified stream

Parameters:
aProductsStorageInputStream - input stream to load a products storage from
Throws:
java.io.IOException - in case of errors during a products storage loading process

LicenseReaderFacade

public LicenseReaderFacade(java.io.File aProductsStorageFile)
                    throws java.io.IOException
Creates a new instance of the LicenseReaderFacade and loads a product storage from the specified file

Parameters:
aProductsStorageFile - file to load a products storage from
Throws:
java.io.IOException - in case of errors during a products storage loading process

LicenseReaderFacade

public LicenseReaderFacade(ProductsStorage aProductsStorage)
Creates a new instance of the LicenseReaderFacade and uses shared and already loaded product storage

Parameters:
aProductsStorage - products storage value
Method Detail

addLicenseReaderListener

public void addLicenseReaderListener(LicenseReaderListener l)
Adds license reader listener.

Parameters:
l - license listener instance.

removeLicenseReaderListener

public void removeLicenseReaderListener(LicenseReaderListener l)
Removes license reader listener.

Parameters:
l - license listener instance.

isSkipEncryption

public boolean isSkipEncryption()
Checks whether license encryption process should be skipped.

Returns:
true license encryption should be skipped, false otherwise.

setSkipEncryption

public void setSkipEncryption(boolean aSkipEncryption)
Specifies that the license encryption process should be skipped. Note: skipping license encryption process can be useful for debugging purposes only.

Parameters:
aSkipEncryption - true if license encryption should be skipped, false otherwise.

readLicense

public License readLicense(java.io.File aFile)

readLicense

public License readLicense(java.io.InputStream anInputStream,
                           java.lang.String aLicenseLocation)

readLicense

public License readLicense(byte[] aLicenseBytes)

licenseAboutToRead

public void licenseAboutToRead(LicenseReader aSource,
                               java.lang.String aProductID)
Description copied from interface: LicenseReaderListener
License reader calls this method to notify listener that the license is about to be read and specifies a known ID of the product this license is issued for. Listener's implementation can employ this method to locate a particular product and assign valid private key bytes to the reader.

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

licenseMissing

public void licenseMissing(LicenseReader aSource,
                           java.lang.String aLicenseLocation)
Description copied from interface: LicenseReaderListener
License reader calls this method to notify listener when the license is not found neither in the resource folder nor in the file system.

Specified by:
licenseMissing in interface LicenseReaderListener
Parameters:
aSource - the license reader.
aLicenseLocation - full path to the license file.

licenseCorrupted

public void licenseCorrupted(LicenseReader aSource,
                             java.lang.String aLicenseLocation)
Description copied from interface: LicenseReaderListener
License reader calls this method to notify listener that the license is corrupted and therefore can not be read.

Specified by:
licenseCorrupted in interface LicenseReaderListener
Parameters:
aSource - the license reader.
aLicenseLocation - full path to the license file.

licenseAvailable

public void licenseAvailable(LicenseReader aSource,
                             java.lang.String aLicenseLocation)
Description copied from interface: LicenseReaderListener
License reader calls this method to notify listener that the license is successfully read and available for use.

Specified by:
licenseAvailable in interface LicenseReaderListener
Parameters:
aSource - the license reader.
aLicenseLocation - full path to the license file.

isVerbose

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

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

setVerbose

public void setVerbose(boolean aVerbose)
Specifies that facade should run in verbose mode. If facade run in verbose mode all thrown exceptions and stack traces will be printed out to the stderr. Otherwise there is no output generated in order to prevent the "code flow" analysis.

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