TrueLicense Core 1.33

de.schlichtherle.license
Class PrivacyGuard

java.lang.Object
  extended by de.schlichtherle.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.

Author:
Christian Schlichtherle

Field Summary
private  AlgorithmParameterSpec algoParamSpec
           
private  Cipher cipher
           
private  SecretKey key
           
private  CipherParam param
           
private static String PBE_WITH_MD5_AND_DES
           
 
Constructor Summary
protected PrivacyGuard()
          Creates a new Privacy Guard.
  PrivacyGuard(CipherParam param)
          Creates a new Privacy Guard.
 
Method Summary
 byte[] cert2key(GenericCertificate certificate)
          Encodes, compresses and encrypts the given license certificate and returns the result as a license key.
 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.
private  void setCipherParam0(CipherParam param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

algoParamSpec

private AlgorithmParameterSpec algoParamSpec

cipher

private Cipher cipher

key

private SecretKey key

param

private CipherParam param

PBE_WITH_MD5_AND_DES

private static final String PBE_WITH_MD5_AND_DES
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

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.

getCipherParam

public CipherParam getCipherParam()
Returns the cipher configuration parameters.


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.

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.

setCipherParam0

private void setCipherParam0(CipherParam param)

TrueLicense Core 1.33

Copyright © 2005-2015 Schlichtherle IT Services. All Rights Reserved.