TrueLicense Core 1.33

de.schlichtherle.license
Class LicenseNotary

java.lang.Object
  extended by de.schlichtherle.license.LicenseNotary

public class LicenseNotary
extends Object

This notary knows how to sign and verify a GenericCertificate.

This class is not thread safe.

Author:
Christian Schlichtherle

Field Summary
private static String ALIAS
          => "alias"
private static int BUFSIZE
          The buffer size for I/O.
private static String EXC_NO_CERTIFICATE_ENTRY
          => "exc.noCertificateEntry"
private static String EXC_NO_KEY_ENTRY
          => "exc.noKeyEntry"
private static String EXC_NO_KEY_PWD
          => "exc.noKeyPwd"
private static String EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED
          => "exc.privateKeyOrPwdIsNotAllowed"
private static String JKS
          => "JKS"
private  KeyStore keyStore
           
private  KeyStoreParam param
           
(package private) static String PARAM
          => "param"
private  PrivateKey privateKey
           
private  PublicKey publicKey
           
private static String SHA1_WITH_DSA
          => "SHA1withDSA"
 
Constructor Summary
protected LicenseNotary()
          Creates a new License Notary.
  LicenseNotary(KeyStoreParam param)
          Creates a new License Notary.
 
Method Summary
protected  KeyStore getKeyStore()
          Returns a loaded/initialized keyStore.
 KeyStoreParam getKeyStoreParam()
          Returns the keyStore configuration parameters.
protected  PrivateKey getPrivateKey()
          Returns the private key from the keyStore.
protected  PublicKey getPublicKey()
          Returns the public key from the keyStore
protected  Signature getSignatureEngine()
          Returns a valid signature engine to be used for signing and verifying a GenericCertificate - null is never returned.
 void setKeyStoreParam(KeyStoreParam param)
          Sets the keyStore configuration parameters.
private  void setKeyStoreParam0(KeyStoreParam param)
           
(package private)  void sign(GenericCertificate certificate, Object content)
          Encodes and signs the given content in the given certificate and locks it.
 GenericCertificate sign(Object content)
          Encodes and signs the given content and returns a locked generic certificate holding the encoded content and its digital signature.
 void verify(GenericCertificate certificate)
          Verifies the digital signature of the encoded content in the given certificate and locks it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALIAS

private static final String ALIAS
=> "alias"


BUFSIZE

private static final int BUFSIZE
The buffer size for I/O.

See Also:
Constant Field Values

EXC_NO_CERTIFICATE_ENTRY

private static final String EXC_NO_CERTIFICATE_ENTRY
=> "exc.noCertificateEntry"


EXC_NO_KEY_ENTRY

private static final String EXC_NO_KEY_ENTRY
=> "exc.noKeyEntry"


EXC_NO_KEY_PWD

private static final String EXC_NO_KEY_PWD
=> "exc.noKeyPwd"


EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED

private static final String EXC_PRIVATE_KEY_OR_PWD_IS_NOT_ALLOWED
=> "exc.privateKeyOrPwdIsNotAllowed"


JKS

private static final String JKS
=> "JKS"


keyStore

private KeyStore keyStore

param

private KeyStoreParam param

PARAM

static final String PARAM
=> "param"


privateKey

private PrivateKey privateKey

publicKey

private PublicKey publicKey

SHA1_WITH_DSA

private static final String SHA1_WITH_DSA
=> "SHA1withDSA"

Constructor Detail

LicenseNotary

protected LicenseNotary()
Creates a new License Notary.

Warning: The notary created by this constructor is not valid and cannot be used unless setKeyStoreParam(KeyStoreParam) is called!


LicenseNotary

public LicenseNotary(KeyStoreParam param)
Creates a new License Notary.

Parameters:
param - the keyStore 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.
Method Detail

getKeyStore

protected KeyStore getKeyStore()
                        throws IOException,
                               CertificateException,
                               NoSuchAlgorithmException
Returns a loaded/initialized keyStore.

Throws:
IOException - if there is an I/O or format problem with the keyStore data.
CertificateException - if any of the certificates in the keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check the integrity of the keyStore cannot be found.

getKeyStoreParam

public KeyStoreParam getKeyStoreParam()
Returns the keyStore configuration parameters.


getPrivateKey

protected PrivateKey getPrivateKey()
                            throws LicenseNotaryException,
                                   IOException,
                                   CertificateException,
                                   NoSuchAlgorithmException,
                                   UnrecoverableKeyException
Returns the private key from the keyStore.

Throws:
LicenseNotaryException - if the parameters used to access the corresponding key store are insufficient or incorrect. Note that you should always use Throwable.getLocalizedMessage() to get a (possibly localized) meaningful detail message.
IOException - if there is an I/O or format problem with the keyStore data.
CertificateException - if any of the certificates in the keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check the integrity of the keyStore cannot be found.
UnrecoverableKeyException - if the key cannot get recovered (e.g. the given password is wrong).

getPublicKey

protected PublicKey getPublicKey()
                          throws LicenseNotaryException,
                                 IOException,
                                 CertificateException,
                                 NoSuchAlgorithmException
Returns the public key from the keyStore

Throws:
LicenseNotaryException - if the parameters used to access the corresponding key store are insufficient or incorrect. Note that you should always use Throwable.getLocalizedMessage() to get a (possibly localized) meaningful detail message.
IOException - if there is an I/O or format problem with the keyStore data.
CertificateException - if any of the certificates in the keyStore could not be loaded.
NoSuchAlgorithmException - if the algorithm used to check the integrity of the keyStore cannot be found.

getSignatureEngine

protected Signature getSignatureEngine()
Returns a valid signature engine to be used for signing and verifying a GenericCertificate - null is never returned.


setKeyStoreParam

public void setKeyStoreParam(KeyStoreParam param)
Sets the keyStore configuration parameters. Calling this method resets the notary as if it had just been created.

Parameters:
param - the keyStore 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.

setKeyStoreParam0

private void setKeyStoreParam0(KeyStoreParam param)

sign

void sign(GenericCertificate certificate,
          Object content)
    throws Exception
Encodes and signs the given content in the given certificate and locks it.

Please note the following:

Parameters:
certificate - the generic certificate used to hold the encoded content and its digital signature.
content - the object to sign. This must either be a JavaBean or an instance of any other class which is supported by {@link de.schlichtherle.xml.PersistenceService} - maybe null.
Throws:
Exception - for various reasons.

sign

public GenericCertificate sign(Object content)
                        throws Exception
Encodes and signs the given content and returns a locked generic certificate holding the encoded content and its digital signature.

Please note the following:

Parameters:
content - the object to sign. This must either be a JavaBean or an instance of any other class which is supported by PersistenceService - maybe null.
Returns:
A locked generic certificate holding the encoded content and its digital signature.
Throws:
Exception - for various reasons.

verify

public void verify(GenericCertificate certificate)
            throws Exception
Verifies the digital signature of the encoded content in the given certificate and locks it.

Please note the following:

Parameters:
certificate - the generic certificate to verify - may not be null.
Throws:
Exception - a subclass of this class may be thrown for various reasons.

TrueLicense Core 1.33

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