Package org.zkoss.zkex.license
Class PrivacyGuard
- java.lang.Object
-
- org.zkoss.zkex.license.PrivacyGuard
-
public class PrivacyGuard extends java.lang.ObjectThis class provides encoding and encryption services to provide long time persistence forGenericCertificates and protect the privacy of its data.This class is not thread safe.
- Version:
- $Id$
- Author:
- Christian Schlichtherle
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPrivacyGuard()Creates a new Privacy Guard.PrivacyGuard(CipherParam param)Creates a new Privacy Guard.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]cert2key(GenericCertificate certificate)Encodes, compresses and encrypts the given license certificate and returns the result as a license key.protected javax.crypto.CiphergetCipher()Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality.protected javax.crypto.CiphergetCipher4Decryption()Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality.protected javax.crypto.CiphergetCipher4Encryption()Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality.CipherParamgetCipherParam()Returns the cipher configuration parameters.GenericCertificatekey2cert(byte[] key)Decrypts, decompresses and decodes the given license key and returns the result as a license certificate.voidsetCipherParam(CipherParam param)Sets the cipher configuration parameters.
-
-
-
Constructor Detail
-
PrivacyGuard
protected PrivacyGuard()
Creates a new Privacy Guard.Warning: The guard created by this constructor is not valid and cannot be used unless
setCipherParam(CipherParam)is called!
-
PrivacyGuard
public PrivacyGuard(CipherParam param)
Creates a new Privacy Guard.- Parameters:
param- The cipher configuration parameters - may not benull.
-
-
Method Detail
-
getCipherParam
public CipherParam getCipherParam()
Returns the cipher configuration parameters.
-
setCipherParam
public void setCipherParam(CipherParam param)
Sets the cipher configuration parameters. Calling this method resets the guard as if it had been newly created. Some plausibility checks are applied to the given parameter object to ensure that it adheres to the contract of the parameter interfaces.- Parameters:
param- the cipher configuration parameters - may not benull.- Throws:
java.lang.NullPointerException- if the given parameter object does not obey the contract of its interface due to anullpointer.IllegalPasswordException- if any password in the parameter object does not comply to the current policy.
-
cert2key
public byte[] cert2key(GenericCertificate certificate) throws java.lang.Exception
Encodes, compresses and encrypts the given license certificate and returns the result as a license key. Please note that this method does not sign the certificate.- Parameters:
certificate- The license certificate - may not benull.- Returns:
- The license key
-
nullis never returned. - Throws:
java.lang.Exception- An instance of a subclass of this class for various reasons. Note that you should always useThrowable.getLocalizedMessage()to get a (possibly localized) meaningful detail message.
-
key2cert
public GenericCertificate key2cert(byte[] key) throws java.lang.Exception
Decrypts, decompresses and decodes the given license key and returns the result as a license certificate. Please note that this method does not verify the certificate.- Parameters:
key- The license key to process - may not benull.- Returns:
- The license certificate
-
nullis never returned. - Throws:
java.lang.Exception- An instance of a subclass of this class for various reasons. Note that you should always useThrowable.getLocalizedMessage()to get a (possibly localized) meaningful detail message.
-
getCipher4Encryption
protected javax.crypto.Cipher getCipher4Encryption()
Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality. Most likely the methods will prevail however and this note will just vanish, so you may use them with a certain risk.Returns a cipher object which is initialised for encryption -nullis never returned.
-
getCipher4Decryption
protected javax.crypto.Cipher getCipher4Decryption()
Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality. Most likely the methods will prevail however and this note will just vanish, so you may use them with a certain risk.Returns a cipher object which is initialised for decryption -nullis never returned.
-
getCipher
protected javax.crypto.Cipher getCipher()
Deprecated.Experimental: Methods marked with this note have been tested to be functional but may change or disappear at will in one of the next releases because they are still a topic for research on extended functionality. Most likely the methods will prevail however and this note will just vanish, so you may use them with a certain risk.Returns a cipher object which needs to be configured for encryption or decryption -nullis never returned.
-
-