|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jp.protection.priv.products.ProductsStorage
public class ProductsStorage
Container class for holding and maintaining products
Nested Class Summary | |
---|---|
(package private) static class |
ProductsStorage.LicenseAliasHashedListStrategy
|
static interface |
ProductsStorage.PasswordResolver
|
static class |
ProductsStorage.ProductIDHashedListStrategy
|
Field Summary | |
---|---|
protected dev.util.collections.HashedBoundList |
fLicenseAliases
|
protected LicensingFacadeConfig |
fLicensingFacadeConfig
|
protected boolean |
fModified
|
protected ProductsStorage.PasswordResolver |
fPasswordResolver
|
protected dev.util.collections.HashedBoundList |
fProducts
|
protected java.io.File |
fProductsFile
|
protected java.lang.String |
fReadPassword
|
protected char[] |
fSerialNumberKeyChars
|
protected int |
fSerialNumberSequence
|
protected int |
fSerialNumberVersion
|
protected java.util.HashMap |
fShortIDProductMap
|
protected int |
fVersion
|
protected boolean |
fWriteEnabled
|
protected byte[] |
fWritePasswordDigest
|
static int |
SERIAL_NUMBER_VERSION
|
static java.lang.String |
SIGNATURE_ENCRYPTED
|
static int |
VERSION
|
Constructor Summary | |
---|---|
ProductsStorage()
Creates a new instance of the ProductsStorage |
Method Summary | |
---|---|
void |
addProductsStorageListener(ProductsStorageListener l)
Adds products storage listener to the list of listeners |
protected void |
assignProductShortIDs()
|
boolean |
canLoad()
Returns whether is possible to load products storage from the file specified by the setProductsFile() call |
protected void |
convertProducts()
|
boolean |
convertSecurityKeys()
|
protected byte[] |
decrypt(byte[] aBytes)
|
boolean |
doNew()
Initialize products storage to an empty storage state |
void |
elementAdded(java.lang.Object anElement,
java.lang.Object aSource)
|
void |
elementRemoved(java.lang.Object anElement,
java.lang.Object aSource)
|
void |
elementsAdded(java.util.Collection anElements,
java.lang.Object aSource)
|
void |
elementsRemoved(java.util.Collection anElements,
java.lang.Object aSource)
|
protected byte[] |
encrypt(byte[] aBytes)
|
protected void |
fireBeforeProductsStorageSave()
|
protected void |
fireProductAdded(Product aProduct)
|
protected void |
fireProductDeleted(Product aProduct)
|
protected void |
fireProductsStorageLoaded()
|
protected void |
fireProductsStorageSaved()
|
void |
fireProductUpdated(Product aProduct)
Notifies all registered listeners that particular project is updated |
protected int |
generateProductShortID()
|
void |
generateSerialNumberKeyChars()
Generates random key characters |
protected javax.crypto.Cipher |
getCipher(boolean isEncrypt)
|
java.util.List<Product> |
getClonedProducts()
Returns the list of clones of products contained in the storage |
java.util.List |
getEnabledProducts()
Returns the list of enabled products contained in the storage. |
protected java.io.InputStream |
getInputStream()
|
LicenseBase |
getLicense(SerialNumber aSerialNumber)
Returns license by its Serial Number |
LicenseBase |
getLicense(java.lang.String aSerialNumber)
Returns license by its Serial Number |
LicenseAlias |
getLicenseAlias(java.lang.String anAlias)
|
dev.util.collections.HashedBoundList |
getLicenseAliases()
|
LicensingFacadeConfig |
getLicensingFacadeConfig()
Returns licensing facade configuration associated with the product's storage |
protected java.io.OutputStream |
getOutputStream()
|
ProductsStorage.PasswordResolver |
getPasswordResolver()
|
Product |
getProduct(int anIndex)
Returns a product by its index |
Product |
getProduct(java.lang.String anID)
Returns a product by its identifier |
Product |
getProductByShortID(int aShortID)
Returns a product by its aShortID identifier |
java.util.List<Product> |
getProducts()
Returns the list of products contained in the storage |
java.io.File |
getProductsFile()
Returns products storage file |
java.lang.String |
getReadPassword()
|
SerialNumber |
getSerialNumber()
Creates and returns a new Serial Number |
SerialNumber |
getSerialNumber(LicenseBase aLicense)
Creates Serial Number for specified license |
SerialNumber2 |
getSerialNumber2()
Creates and returns a new Serial Number |
char[] |
getSerialNumberKeyChars()
Returns serial number key characters |
int |
getSerialNumberVersion()
|
int |
getVersion()
|
byte[] |
getWritePasswordDigest()
|
boolean |
isModified()
Returns whether this products storage is modified |
boolean |
isReadOnly()
Returns whether this products storage has a read-only attribute by checking the file specified by the setProductsFile() call |
boolean |
isWriteEnabled()
|
boolean |
load()
Loads products storage from the file specified by the setProductsFile() call |
boolean |
load(java.io.InputStream anInputStream)
Loads products storage from the specified stream |
protected void |
loadData(java.io.InputStream anInputStream)
|
protected boolean |
loadEncryptionSignature(java.io.InputStream anInputStream)
|
protected void |
loadImpl(java.io.ObjectInputStream objectInputStream)
|
boolean |
needConvertSecurityKeys()
|
void |
removeProductsStorageListener(ProductsStorageListener l)
Removes products storage listener from the list of listeners |
boolean |
save()
Save products storage to the file specified by the setProductsFile() call |
boolean |
save(java.io.OutputStream anOutputStream)
Saves products storage to the specified stream |
protected void |
saveData(java.io.OutputStream anOutputStream)
|
protected void |
saveEncryptionSignature(java.io.OutputStream anOutputStream)
|
protected void |
saveImpl(java.io.ObjectOutputStream objectOutputStream)
|
void |
setModified(boolean aModified)
Marks this storage as modifed |
void |
setPasswordResolver(ProductsStorage.PasswordResolver aPasswordResolver)
|
void |
setProductsFile(java.io.File aProductsFile)
Specifies products storage file |
void |
setReadPassword(java.lang.String aReadPassword)
|
void |
setSerialNumberVersion(int aSerialNumberVersion)
|
void |
setVersion(int aVersion)
|
void |
setWriteEnabled(boolean aWriteEnabled)
|
void |
setWritePasswordDigest(byte[] aWritePasswordDigest)
|
void |
toLicense(SerialNumber aSerialNumber,
LicenseBaseImpl aLicense)
Updates specified license by provided Serial Number's attributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient java.util.HashMap fShortIDProductMap
protected dev.util.collections.HashedBoundList fProducts
protected dev.util.collections.HashedBoundList fLicenseAliases
protected byte[] fWritePasswordDigest
protected transient boolean fWriteEnabled
protected char[] fSerialNumberKeyChars
protected int fSerialNumberSequence
public static final java.lang.String SIGNATURE_ENCRYPTED
protected transient java.lang.String fReadPassword
protected ProductsStorage.PasswordResolver fPasswordResolver
protected java.io.File fProductsFile
protected boolean fModified
protected LicensingFacadeConfig fLicensingFacadeConfig
public static final int SERIAL_NUMBER_VERSION
public static final int VERSION
protected int fSerialNumberVersion
protected int fVersion
Constructor Detail |
---|
public ProductsStorage()
ProductsStorage
Method Detail |
---|
public dev.util.collections.HashedBoundList getLicenseAliases()
public LicenseAlias getLicenseAlias(java.lang.String anAlias)
public java.util.List<Product> getProducts()
public java.util.List getEnabledProducts()
public java.util.List<Product> getClonedProducts()
public Product getProduct(java.lang.String anID)
anID
- product's identifier
null
if product with such identifier is not found within the storagepublic Product getProduct(int anIndex)
anIndex
- product's index
public boolean doNew()
true
on success; false
otherwisepublic boolean isWriteEnabled()
public void setWriteEnabled(boolean aWriteEnabled)
public byte[] getWritePasswordDigest()
public void setWritePasswordDigest(byte[] aWritePasswordDigest)
public boolean load(java.io.InputStream anInputStream) throws java.io.IOException
anInputStream
- input stream to load products storage from
true
on success; false
otherwise
java.io.IOException
- in case of any error during the products storage reading processprotected void loadData(java.io.InputStream anInputStream) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected void loadImpl(java.io.ObjectInputStream objectInputStream) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected void convertProducts()
public boolean load() throws java.io.IOException
setProductsFile()
call
true
on success; false
otherwise
java.io.IOException
- in case of any error during the products storage reading processpublic void generateSerialNumberKeyChars()
public char[] getSerialNumberKeyChars()
public SerialNumber getSerialNumber()
SerialNumber
public SerialNumber2 getSerialNumber2()
SerialNumber
public boolean save(java.io.OutputStream anOutputStream) throws java.io.IOException
anOutputStream
- outpit stream to save products storage to
true
on success; false
otherwise
java.io.IOException
- in case of any error during the products storage reading processprotected void saveEncryptionSignature(java.io.OutputStream anOutputStream) throws java.io.IOException
java.io.IOException
protected boolean loadEncryptionSignature(java.io.InputStream anInputStream) throws java.io.IOException
java.io.IOException
protected void saveData(java.io.OutputStream anOutputStream) throws java.io.IOException
java.io.IOException
public java.lang.String getReadPassword()
public void setReadPassword(java.lang.String aReadPassword)
protected byte[] encrypt(byte[] aBytes)
public ProductsStorage.PasswordResolver getPasswordResolver()
public void setPasswordResolver(ProductsStorage.PasswordResolver aPasswordResolver)
protected byte[] decrypt(byte[] aBytes) throws java.io.IOException
java.io.IOException
protected void saveImpl(java.io.ObjectOutputStream objectOutputStream) throws java.io.IOException
java.io.IOException
public boolean save() throws java.io.IOException
setProductsFile()
call
true
on success; false
otherwise
java.io.IOException
- in case of any error during the products storage saving processprotected java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
protected java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
public boolean canLoad()
setProductsFile()
call
true
if it is possible to load products storage; false
otherwisepublic java.io.File getProductsFile()
public void setProductsFile(java.io.File aProductsFile)
aProductsFile
- products storage filepublic void removeProductsStorageListener(ProductsStorageListener l)
l
- products storage listener to removepublic void addProductsStorageListener(ProductsStorageListener l)
l
- products storage listener to addpublic boolean isReadOnly()
setProductsFile()
call
true
if products storage is read-only; false
otherwisepublic boolean isModified()
true
if this products storage is modified; false
otherwisepublic void setModified(boolean aModified)
aModified
- modified valueprotected void fireProductsStorageLoaded()
protected void fireBeforeProductsStorageSave()
protected void fireProductsStorageSaved()
protected void fireProductAdded(Product aProduct)
protected void fireProductDeleted(Product aProduct)
public void fireProductUpdated(Product aProduct)
aProduct
- updated productpublic Product getProductByShortID(int aShortID)
aShortID
- product's short identifier
null
if product with such identifier is not found within the storageprotected int generateProductShortID()
protected void assignProductShortIDs()
public void elementAdded(java.lang.Object anElement, java.lang.Object aSource)
elementAdded
in interface dev.util.collections.ContainerListener
public void elementRemoved(java.lang.Object anElement, java.lang.Object aSource)
elementRemoved
in interface dev.util.collections.ContainerListener
public void elementsAdded(java.util.Collection anElements, java.lang.Object aSource)
elementsAdded
in interface dev.util.collections.ContainerListener
public void elementsRemoved(java.util.Collection anElements, java.lang.Object aSource)
elementsRemoved
in interface dev.util.collections.ContainerListener
public LicensingFacadeConfig getLicensingFacadeConfig()
LicensingFacadeConfig
public LicenseBase getLicense(java.lang.String aSerialNumber) throws SerialNumberException
aSerialNumber
- Serial Number to get the license for
SerialNumberException
- if Serial Number is invalidpublic LicenseBase getLicense(SerialNumber aSerialNumber) throws SerialNumberException
aSerialNumber
- Serial Number to get the license for
SerialNumberException
- if Serial Number is invalidpublic void toLicense(SerialNumber aSerialNumber, LicenseBaseImpl aLicense) throws SerialNumberException
aSerialNumber
- Serial Number to get attributes fromaLicense
- license to update
SerialNumberException
public SerialNumber getSerialNumber(LicenseBase aLicense) throws SerialNumberException
aLicense
- license to get Serial Number for
SerialNumber
SerialNumberException
- if itis impossible to get Serial Number for some reasonpublic int getSerialNumberVersion()
public void setSerialNumberVersion(int aSerialNumberVersion)
public int getVersion()
public void setVersion(int aVersion)
protected javax.crypto.Cipher getCipher(boolean isEncrypt)
public boolean needConvertSecurityKeys()
public boolean convertSecurityKeys()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |