|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jp.protection.pub.LicenseReader
public class LicenseReader
This class is intended to read a license, decode it, hold the already read license and notify interested listeners about reading process and its results.
Nested Class Summary | |
---|---|
static class |
LicenseReader.FileStorage
|
static class |
LicenseReader.InMemoryStorage
|
static interface |
LicenseReader.Storage
|
Field Summary | |
---|---|
protected java.lang.Class |
fClassForLoadLicenseResource
|
protected byte[] |
fDecryptKeyBytes
|
protected License |
fLicense
|
protected java.lang.String |
fLicenseFileName
|
protected java.lang.String |
fLicenseFolder
|
protected boolean |
fLicenseRead
|
protected LicenseReaderIssueResolver |
fLicenseReaderIssueResolver
|
protected java.lang.String |
fLicenseResourceFolder
|
protected boolean |
fPerformLicenseBackups
|
protected boolean |
fSearchLicenseInFile
|
protected java.lang.String |
fSecurityAlgorithm
|
protected SecurityProvider |
fSecurityProvider
|
protected boolean |
fSkipEncryption
|
protected LicenseReader.Storage |
fStorage
|
protected boolean |
fUserHomeRelative
|
protected boolean |
fVerbose
|
Constructor Summary | |
---|---|
LicenseReader()
|
Method Summary | |
---|---|
void |
addLicenseReaderListener(LicenseReaderListener l)
Adds license reader listener |
boolean |
backupLicense()
Performs backup of current license |
boolean |
canRestoreLicenseFromBackup()
Checks whether a license can be restored from backup |
protected void |
checkLicenseFile()
|
protected byte[] |
decodeLicense(byte[] aLicenseBytes)
|
protected void |
error(java.lang.String aMessage)
|
protected void |
error(java.lang.Throwable ex)
|
protected void |
fireLicenseAboutToRead(LicenseReader e,
java.lang.String aProductID)
|
protected void |
fireLicenseAvailable(LicenseReader e,
java.lang.String aLicenseLocation)
|
protected void |
fireLicenseCorrupted(LicenseReader e,
java.lang.String aLicenseLocation)
|
protected void |
fireLicenseMissing(LicenseReader e,
java.lang.String aLicenseLocation)
|
protected void |
fireLicenseRemoved(LicenseReader e,
java.lang.String aLicenseLocation)
|
protected void |
fireLicenseUpdated(LicenseReader e,
java.lang.String aLicenseLocation)
|
java.io.InputStream |
getBackupLicenseInputStream()
Returns input stream for a backed up license |
java.lang.Class |
getClassForLoadLicenseResource()
Returns class used for loading license from the application resource. |
byte[] |
getDecryptKeyBytes()
Returns bytes array that specifies key used to decrypt the license. |
LicenseReaderIssueResolver |
getIssueResolver()
Returns issue resolver used to fix issues occured during license locating and reading. |
License |
getLicense()
Returns already read license. |
License |
getLicense(boolean aForceRead)
Returns already read license. |
byte[] |
getLicenseBytes()
Reads a license file and returns it as an array of bytes |
protected byte[] |
getLicenseBytes(java.io.InputStream aLicenseInputStream)
|
java.io.File |
getLicenseFile()
Constructs and returns file of the license according to the licenseFileName , licenseFolder and
licenseReader attributes. |
java.io.InputStream |
getLicenseFileInputStream()
Returns input stream to read license from file |
java.lang.String |
getLicenseFileLocation()
Returns path of license file |
java.lang.String |
getLicenseFileName()
Returns the license file name, which should be read by the reader. |
java.lang.String |
getLicenseFolder()
Returns path to the folder outside of application archive, which contains the license to be read. |
java.io.InputStream |
getLicenseInputStream()
Returns input stream to read license from |
java.io.OutputStream |
getLicenseOutputStream()
Returns output stream to write license to. |
java.lang.String |
getLicenseProduct(java.io.InputStream aLicenseInputStream)
Reads and returns license product from the specified stream. |
java.lang.String |
getLicenseResourceFolder()
Returns the path to the folder within application archive, which contains the license file. |
java.io.InputStream |
getLicenseResourceInputStream()
Returns input stream to read license from the application resource |
java.lang.String |
getLicenseResourceLocation()
Constructs and returns location of the license resource within the application archive |
byte[] |
getPrivateKeyBytes()
Deprecated. use getDecryptKeyBytes() instead |
java.lang.String |
getSecurityAlgorithm()
Returns identifier of security algorithm used to decode licenses. |
protected SecurityProvider |
getSecurityProvider()
|
LicenseReader.Storage |
getStorage()
|
static java.io.File |
getUserHome()
|
boolean |
isLicenseRead()
Checks whether license is already read. |
boolean |
isPerformLicenseBackups()
Returns whether license backups should be performed when applying a new license |
boolean |
isSearchLicenseInFile()
Returns whether license should be searched in file first |
boolean |
isSkipEncryption()
Checks whether license encryption should be skipped. |
boolean |
isUserHomeRelative()
Checks whether the reader should treat license folder as relative to the user home. |
boolean |
isVerbose()
Checks whether reader runs in verbose mode. |
protected void |
readLicense()
|
protected void |
readLicense(byte[] aLicenseBytes)
|
void |
readLicense(java.io.InputStream aLicenseInputStream,
java.lang.String aLicenseLocation)
Reads the license from the specified stream. |
boolean |
removeLicense()
Removes license from local storage. |
void |
removeLicenseReaderListener(LicenseReaderListener l)
Removes license reader listener. |
boolean |
restoreLicenseFromBackup()
Restores a license from backup |
void |
setClassForLoadLicenseResource(java.lang.Class aClassForLoadLicenseResource)
Specifies class should be used for loading license from the application resource. |
void |
setDecryptKeyBytes(byte[] aDecryptKeyBytes)
Specifies bytes array representing key required to decrypt the license. |
void |
setDecryptKeyBytes(java.lang.String aDecryptKeyBytes)
Specifies bytes array used to restore the key required to decode the license. |
void |
setIssueResolver(LicenseReaderIssueResolver aLicenseReaderIssueResolver)
Specifies issue resolver should be used to fix issues occured during license locating and reading. |
void |
setLicenseFileName(java.lang.String aLicenseFileName)
Specifies the name of the license file |
void |
setLicenseFolder(java.lang.String aLicenseFolder)
Specifies path to the folder, which contains the license to be read. |
void |
setLicenseResourceFolder(java.lang.String aLicenseResourceFolder)
Specifies the path to the resource folder, which contains the license file. |
void |
setPerformLicenseBackups(boolean aValue)
Specifies whether license backups should be performed when applying a new license |
void |
setPrivateKeyBytes(byte[] aPrivateKeyBytes)
Deprecated. use setDecryptKeyBytes() instead |
void |
setPrivateKeyBytes(java.lang.String aPrivateKeyBytes)
Deprecated. use setDecryptKeyBytes() instead |
void |
setSearchLicenseInFile(boolean aSearchLicenseInFile)
Specifies that license should be searched in file first. |
void |
setSecurityAlgorithm(java.lang.String aSecurityAlgorithm)
Specifies identifier of security algorithm should be used to decode licenses. |
void |
setSkipEncryption(boolean aSkipEncryption)
Specifies that license encryption should be skipped. |
void |
setStorage(LicenseReader.Storage aStorage)
|
void |
setUserHomeRelative(boolean aUserHomeRelative)
Specifies that the reader should treat license folder as relative to the user home. |
void |
setVerbose(boolean aVerbose)
Specifies that reader should be run in verbose mode. |
protected byte[] |
smartDecodeLicense(byte[] aLicenseBytes)
|
protected byte[] |
smartGetLicenseBytes(java.io.InputStream aLicenseInputStream)
|
protected void |
smartReadLicense(byte[] aLicenseBytes)
|
boolean |
updateLicense(byte[] aLicenseBytes)
Updates license in the local storage. |
boolean |
updateLicense(java.io.InputStream aNewLicenseInputStream)
Replaces current license with new one optionally performing backup |
boolean |
updateLicense(java.io.InputStream aNewLicenseInputStream,
boolean isMakeBackup)
Replaces current license with new one explicitly specifying whether backup need to be done |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected License fLicense
protected java.lang.String fLicenseFileName
protected boolean fUserHomeRelative
protected java.lang.String fLicenseFolder
protected java.lang.String fLicenseResourceFolder
protected boolean fLicenseRead
protected boolean fVerbose
protected boolean fSkipEncryption
protected byte[] fDecryptKeyBytes
protected LicenseReaderIssueResolver fLicenseReaderIssueResolver
protected boolean fSearchLicenseInFile
protected boolean fPerformLicenseBackups
protected LicenseReader.Storage fStorage
protected SecurityProvider fSecurityProvider
protected java.lang.String fSecurityAlgorithm
protected java.lang.Class fClassForLoadLicenseResource
Constructor Detail |
---|
public LicenseReader()
Method Detail |
---|
public java.lang.String getLicenseResourceFolder()
null
and therefore is not specified the reader will not try to find the license in
the application resources.
public void setLicenseResourceFolder(java.lang.String aLicenseResourceFolder)
aLicenseResourceFolder
- path to the resource folderpublic byte[] getDecryptKeyBytes()
public void setDecryptKeyBytes(byte[] aDecryptKeyBytes)
aDecryptKeyBytes
- decryption key bytespublic void setDecryptKeyBytes(java.lang.String aDecryptKeyBytes)
aDecryptKeyBytes
- private key bytes as String e.g. "1, 23, 45, 23, -1"public byte[] getPrivateKeyBytes()
getDecryptKeyBytes()
instead
public void setPrivateKeyBytes(byte[] aPrivateKeyBytes)
setDecryptKeyBytes()
instead
aPrivateKeyBytes
- private key bytespublic void setPrivateKeyBytes(java.lang.String aPrivateKeyBytes)
setDecryptKeyBytes()
instead
aPrivateKeyBytes
- private key bytes as String e.g. "1, 23, 45, 23, -1"public boolean isLicenseRead()
true
if license is already read, false
otherwise.public boolean isSkipEncryption()
true
license encryption should be skipped, false
otherwise.public void setSkipEncryption(boolean aSkipEncryption)
aSkipEncryption
- true
if license encryption should be skipped, false
otherwise.public boolean isVerbose()
true
if reader runs in verbose mode, false
otherwise.public void setVerbose(boolean aVerbose)
stderr
. Otherwise there is no output in order to prevent the code flow
analysis.
aVerbose
- true
if reader should run in verbose mode,
false
otherwise.protected void error(java.lang.String aMessage)
protected void error(java.lang.Throwable ex)
public boolean isUserHomeRelative()
true
if reader should treat license folder as relative
to the user home, false
otherwise.public void setUserHomeRelative(boolean aUserHomeRelative)
aUserHomeRelative
- true
if reader should treat license folder
as relative to the user home, false
otherwise.public java.lang.String getLicenseFileName()
public void setLicenseFileName(java.lang.String aLicenseFileName)
aLicenseFileName
- name of the license filepublic java.lang.String getLicenseFolder()
public void setLicenseFolder(java.lang.String aLicenseFolder)
aLicenseFolder
- path to the folderpublic License getLicense()
null
if license can't be read.public License getLicense(boolean aForceRead)
aForceRead
- specifies whether license should be re-read if it is already read.
null
if license can not be read.protected void readLicense()
public boolean isSearchLicenseInFile()
true
if license should be searched in file firstpublic void setSearchLicenseInFile(boolean aSearchLicenseInFile)
aSearchLicenseInFile
- true
if license should be searched in file firstpublic java.io.InputStream getLicenseInputStream()
public java.io.OutputStream getLicenseOutputStream()
public boolean isPerformLicenseBackups()
true
if license backups should be performed when applying a new license; false
otherwisepublic void setPerformLicenseBackups(boolean aValue)
aValue
- true
if license backups should be performed when applying a new license; false
otherwisepublic boolean backupLicense()
true
if the license has been backed up; false
otherwisepublic boolean canRestoreLicenseFromBackup()
true
if a license can be restored from backup; false
otherwisepublic boolean restoreLicenseFromBackup()
true
if license has been restored from backup; false
otherwisepublic java.io.InputStream getBackupLicenseInputStream()
public boolean updateLicense(java.io.InputStream aNewLicenseInputStream) throws java.io.IOException
aNewLicenseInputStream
- input stream for reading a new license
true
if current license has been replaced with new one; false
otherwise
java.io.IOException
- for any exception occured during reading/writing of licensespublic boolean updateLicense(java.io.InputStream aNewLicenseInputStream, boolean isMakeBackup) throws java.io.IOException
aNewLicenseInputStream
- input stream for reading a new licenseisMakeBackup
- true
if backup need to be done; false
otherwise
true
if current license has been replaced with new one; false
otherwise
java.io.IOException
- for any exception occured during reading/writing of licensesprotected void checkLicenseFile() throws java.lang.IllegalStateException
java.lang.IllegalStateException
public LicenseReader.Storage getStorage()
public void setStorage(LicenseReader.Storage aStorage)
public void readLicense(java.io.InputStream aLicenseInputStream, java.lang.String aLicenseLocation) throws java.io.IOException
aLicenseInputStream
- stream to read license fromaLicenseLocation
- optional license location information that will be passed to License Reader events.
java.io.IOException
- for any errors occured during license reading.protected byte[] smartDecodeLicense(byte[] aLicenseBytes)
protected byte[] decodeLicense(byte[] aLicenseBytes)
public java.lang.String getSecurityAlgorithm()
public void setSecurityAlgorithm(java.lang.String aSecurityAlgorithm)
aSecurityAlgorithm
- identifier of security algorithm.protected SecurityProvider getSecurityProvider()
protected void smartReadLicense(byte[] aLicenseBytes)
protected void readLicense(byte[] aLicenseBytes)
public java.lang.String getLicenseProduct(java.io.InputStream aLicenseInputStream)
aLicenseInputStream
- stream to read license product from.
protected byte[] smartGetLicenseBytes(java.io.InputStream aLicenseInputStream)
protected byte[] getLicenseBytes(java.io.InputStream aLicenseInputStream)
public java.lang.String getLicenseFileLocation()
public java.lang.String getLicenseResourceLocation()
public java.io.InputStream getLicenseFileInputStream()
public java.io.InputStream getLicenseResourceInputStream()
public java.lang.Class getClassForLoadLicenseResource()
public void setClassForLoadLicenseResource(java.lang.Class aClassForLoadLicenseResource)
LicenseReader
class is used.
aClassForLoadLicenseResource
- class should be used for loading license from the application resource.public static java.io.File getUserHome()
public java.io.File getLicenseFile()
licenseFileName
, licenseFolder
and
licenseReader
attributes.
public void addLicenseReaderListener(LicenseReaderListener l)
l
- license listener instance.public void removeLicenseReaderListener(LicenseReaderListener l)
l
- license listener instance.protected void fireLicenseMissing(LicenseReader e, java.lang.String aLicenseLocation)
protected void fireLicenseCorrupted(LicenseReader e, java.lang.String aLicenseLocation)
protected void fireLicenseAvailable(LicenseReader e, java.lang.String aLicenseLocation)
protected void fireLicenseAboutToRead(LicenseReader e, java.lang.String aProductID)
public LicenseReaderIssueResolver getIssueResolver()
public void setIssueResolver(LicenseReaderIssueResolver aLicenseReaderIssueResolver)
aLicenseReaderIssueResolver
- issue resolverpublic byte[] getLicenseBytes()
protected void fireLicenseRemoved(LicenseReader e, java.lang.String aLicenseLocation)
protected void fireLicenseUpdated(LicenseReader e, java.lang.String aLicenseLocation)
public boolean removeLicense()
getLicense(true)
must be called explicitly to apply that change.
true
if license was removed; false
otherwise.public boolean updateLicense(byte[] aLicenseBytes) throws java.io.IOException
getLicense(true)
must be called explicitly to apply that change.
aLicenseBytes
- byte[] license bytes
java.io.IOException
- if writing failed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |