Class PrivacyGuard


  • public class PrivacyGuard
    extends java.lang.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 PrivacyGuard()
      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.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.
      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.
      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.
      CipherParam getCipherParam()
      Returns the cipher configuration parameters.
      GenericCertificate key2cert​(byte[] key)
      Decrypts, decompresses and decodes the given license key and returns the result as a license certificate.
      void setCipherParam​(CipherParam param)
      Sets the cipher configuration parameters.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 be null.
    • 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 be null.
        Throws:
        java.lang.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 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 be null.
        Returns:
        The license key - null is never returned.
        Throws:
        java.lang.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 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 be null.
        Returns:
        The license certificate - null is never returned.
        Throws:
        java.lang.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 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 - null is 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 - null is 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 - null is never returned.