com.jp.protection.pub.pro.ls
Class JarLicenseStorage

java.lang.Object
  extended by com.jp.protection.pub.pro.ls.BasicLicenseStorage
      extended by com.jp.protection.pub.pro.ls.JarLicenseStorage
All Implemented Interfaces:
LicenseStorage, java.beans.PropertyChangeListener, java.util.EventListener

public class JarLicenseStorage
extends BasicLicenseStorage

Jar file based implementation of the LicenseStorage

Since:
3.0

Nested Class Summary
 
Nested classes/interfaces inherited from class com.jp.protection.pub.pro.ls.BasicLicenseStorage
BasicLicenseStorage.BasicLicenseEntry, BasicLicenseStorage.EntryLicenseReader
 
Nested classes/interfaces inherited from interface com.jp.protection.pub.pro.ls.LicenseStorage
LicenseStorage.LicenseEntry
 
Field Summary
static byte[] COOKIE
           
protected static byte[] EMPTY_LICENSE_BYTES
           
static java.lang.String EXTENSION_LICENSE_ENTRY
           
protected  java.security.MessageDigest fMessageDigest
           
protected  boolean fSeparateLicense
           
static java.util.jar.Attributes.Name PROPERTY_DIGEST
           
static java.util.jar.Attributes.Name PROPERTY_SEPARATE_LICENSE
           
static java.lang.String ROOT_LICENSE_ENTRIES
           
 
Fields inherited from class com.jp.protection.pub.pro.ls.BasicLicenseStorage
fLicenseEntryIDMap, fLicenseEntryMap, fLicenseStorageListeners, fModified
 
Fields inherited from interface com.jp.protection.pub.pro.ls.LicenseStorage
ANY_LICENSE_TYPE, ANY_MAJOR_VERSION, ANY_MINOR_VERSION, ANY_PRODUCT, ANY_PRODUCT_EDITION, ANY_USER_LICENSING_MODEL
 
Constructor Summary
JarLicenseStorage()
           
 
Method Summary
protected  void addJarEntry(java.util.jar.JarOutputStream jarOutputStream, java.io.InputStream anInputStream, java.lang.String anEntryName)
           
 LicenseReader createLicenseReader(java.lang.String aLicenseEntryName)
          Creates and returns LicenseReader instance capable of reading license from the license storage
protected  java.util.jar.Manifest createManifest()
           
protected  byte[] getDigest()
           
protected  java.io.InputStream getInputStream(LicenseStorage.LicenseEntry aLicenseEntry)
           
protected  java.lang.String getJarEntryName(LicenseStorage.LicenseEntry anEntry)
           
protected  java.lang.String getLicenseBytesEntryName(java.util.jar.JarEntry aJarEntry)
           
protected  java.lang.String getLicenseBytesJarEntryName(LicenseStorage.LicenseEntry anEntry)
           
protected  java.lang.String getLicenseEntryName(java.util.jar.JarEntry aJarEntry)
           
protected  java.io.InputStream getLicenseInputStream(LicenseStorage.LicenseEntry aLicenseEntry)
           
protected  java.security.MessageDigest getMessageDigest()
           
protected  boolean isLicenseBytesEntry(java.util.jar.JarEntry aJarEntry)
           
 boolean isSeparateLicense()
          Returns whether license entry and license itself should be stored as different entries in the Jar file
 void load(java.io.File aFile)
          Loads license storage from the Jar file
 void load(java.io.InputStream anInputStream)
          Loads license storage from the given stream
protected  void loadLicenseEntry(java.util.jar.JarInputStream aJarInputStream, java.util.jar.JarEntry aJarEntry)
           
protected  void resetDigest()
           
 void setSeparateLicense(boolean aSeparateLicense)
          Specifies that license entry and license itself should be stored as different entries in the Jar file
 void store(java.io.File aFile)
          Stores license storage to the Jar file
 void store(java.io.OutputStream anOutputStream)
          Stores license storage to the given stream
protected  void storeLicenseEntries(java.util.jar.JarOutputStream jarOutputStream)
           
protected  void updateDigest(byte[] aBytes)
           
 
Methods inherited from class com.jp.protection.pub.pro.ls.BasicLicenseStorage
addLicenseEntry, addLicenseEntryImpl, addLicenseStorageListener, assignNewID, calculateCurrentID, checkLicenseExistence, createLicenseEntry, fireBeforeLicenseStorageLoad, fireBeforeLicenseStorageSave, fireLicenseEntryAdded, fireLicenseEntryRemoved, fireLicenseEntryUpdated, fireLicenseStorageLoaded, fireLicenseStorageSaved, getLicenseEntries, getLicenseEntries, getLicenseEntries, getLicenseEntry, getLicenseEntry, getLicenseEntryForLicenseNumber, getLicenseEntryPath, getLicenseEntryShortName, getName, getNewID, getNewLicenseEntryName, isModified, propertyChange, removeLicenseEntry, removeLicenseStorageListener, setModified, updateLicenseEntry, updateLicenseEntryImpl, updateLicenseEntryProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_LICENSE_ENTRIES

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

EXTENSION_LICENSE_ENTRY

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

PROPERTY_DIGEST

public static final java.util.jar.Attributes.Name PROPERTY_DIGEST

PROPERTY_SEPARATE_LICENSE

public static final java.util.jar.Attributes.Name PROPERTY_SEPARATE_LICENSE

COOKIE

public static final byte[] COOKIE

fSeparateLicense

protected boolean fSeparateLicense

EMPTY_LICENSE_BYTES

protected static final byte[] EMPTY_LICENSE_BYTES

fMessageDigest

protected java.security.MessageDigest fMessageDigest
Constructor Detail

JarLicenseStorage

public JarLicenseStorage()
Method Detail

load

public void load(java.io.File aFile)
          throws java.io.IOException
Loads license storage from the Jar file

Parameters:
aFile - Jar file to load license storage from
Throws:
java.io.IOException - for any errors occured during loading

load

public void load(java.io.InputStream anInputStream)
          throws java.io.IOException
Description copied from interface: LicenseStorage
Loads license storage from the given stream

Parameters:
anInputStream - stream to load license storage from
Throws:
java.io.IOException - for any errors occured during loading

isLicenseBytesEntry

protected boolean isLicenseBytesEntry(java.util.jar.JarEntry aJarEntry)

loadLicenseEntry

protected void loadLicenseEntry(java.util.jar.JarInputStream aJarInputStream,
                                java.util.jar.JarEntry aJarEntry)
                         throws java.io.IOException
Throws:
java.io.IOException

getLicenseEntryName

protected java.lang.String getLicenseEntryName(java.util.jar.JarEntry aJarEntry)

getLicenseBytesEntryName

protected java.lang.String getLicenseBytesEntryName(java.util.jar.JarEntry aJarEntry)

store

public void store(java.io.File aFile)
           throws java.io.IOException
Stores license storage to the Jar file

Parameters:
aFile - Jar file to store license storage to
Throws:
java.io.IOException - for any errors occured during storing

store

public void store(java.io.OutputStream anOutputStream)
           throws java.io.IOException
Description copied from interface: LicenseStorage
Stores license storage to the given stream

Parameters:
anOutputStream - stream to store license storage to
Throws:
java.io.IOException - for any errors occured during storing

createManifest

protected java.util.jar.Manifest createManifest()

storeLicenseEntries

protected void storeLicenseEntries(java.util.jar.JarOutputStream jarOutputStream)
                            throws java.io.IOException
Throws:
java.io.IOException

isSeparateLicense

public boolean isSeparateLicense()
Returns whether license entry and license itself should be stored as different entries in the Jar file

Returns:
true if license entry and license itself should be stored as different entries in the Jar file; false otherwise

setSeparateLicense

public void setSeparateLicense(boolean aSeparateLicense)
Specifies that license entry and license itself should be stored as different entries in the Jar file

Parameters:
aSeparateLicense - true if license entry and license itself should be stored as different entries in the Jar file; false otherwise

getJarEntryName

protected java.lang.String getJarEntryName(LicenseStorage.LicenseEntry anEntry)

getLicenseBytesJarEntryName

protected java.lang.String getLicenseBytesJarEntryName(LicenseStorage.LicenseEntry anEntry)

getInputStream

protected java.io.InputStream getInputStream(LicenseStorage.LicenseEntry aLicenseEntry)
                                      throws java.io.IOException
Throws:
java.io.IOException

getLicenseInputStream

protected java.io.InputStream getLicenseInputStream(LicenseStorage.LicenseEntry aLicenseEntry)
                                             throws java.io.IOException
Throws:
java.io.IOException

addJarEntry

protected void addJarEntry(java.util.jar.JarOutputStream jarOutputStream,
                           java.io.InputStream anInputStream,
                           java.lang.String anEntryName)
                    throws java.io.IOException
Throws:
java.io.IOException

updateDigest

protected void updateDigest(byte[] aBytes)

resetDigest

protected void resetDigest()

getDigest

protected byte[] getDigest()

getMessageDigest

protected java.security.MessageDigest getMessageDigest()

createLicenseReader

public LicenseReader createLicenseReader(java.lang.String aLicenseEntryName)
Description copied from interface: LicenseStorage
Creates and returns LicenseReader instance capable of reading license from the license storage

Parameters:
aLicenseEntryName - name of the license entry to get License Reader for
Returns:
LicenseReader instance