Class PrivacyGuard

java.lang.Object
org.zkoss.zkex.license.PrivacyGuard

public class PrivacyGuard extends Object
This class provides encoding and encryption services to provide long time persistence for GenericCertificates and protect the privacy of its data.

This class is not thread safe.

Version:
$Id$
Author:
Christian Schlichtherle
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new Privacy Guard.
     
    Creates a new Privacy Guard.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Encodes, compresses and encrypts the given license certificate and returns the result as a license key.
    protected Cipher
    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 Cipher
    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 Cipher
    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.
    Returns the cipher configuration parameters.
    key2cert(byte[] key)
    Decrypts, decompresses and decodes the given license key and returns the result as a license certificate.
    void
    Sets the cipher configuration parameters.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 be null.
  • Method Details

    • 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 be null.
      Throws:
      NullPointerException - if the given parameter object does not obey the contract of its interface due to a null pointer.
      IllegalPasswordException - if any password in the parameter object does not comply to the current policy.
    • cert2key

      public byte[] cert2key(GenericCertificate certificate) throws 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 be null.
      Returns:
      The license key - null is never returned.
      Throws:
      Exception - An instance of a subclass of this class for various reasons. Note that you should always use Throwable.getLocalizedMessage() to get a (possibly localized) meaningful detail message.
    • key2cert

      public GenericCertificate key2cert(byte[] key) throws 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 be null.
      Returns:
      The license certificate - null is never returned.
      Throws:
      Exception - An instance of a subclass of this class for various reasons. Note that you should always use Throwable.getLocalizedMessage() to get a (possibly localized) meaningful detail message.
    • getCipher4Encryption

      protected 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 - null is never returned.
    • getCipher4Decryption

      protected 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 - null is never returned.
    • getCipher

      protected 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 - null is never returned.