com.pcbsys.nirvana.client.nCertificateValidator Class Reference

This class validates signatures signed by the nCertificateSigner class. More...

Inheritance diagram for com.pcbsys.nirvana.client.nCertificateValidator:
com.pcbsys.nirvana.client.nMessageValidator

Public Member Functions

Object check (byte[] original) throws Exception
 Performs the validation with the original signature against the signature created with the update methods. More...
 
java.security.cert.Certificate[] getLoadedCertificates ()
 Returns an array of certificates that this object is using to valdiate the signature. More...
 
Provider getProvider ()
 Return the Provider used to vend the Signature class. More...
 
 nCertificateValidator (java.security.cert.X509Certificate[] certificates) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException
 Constructs the validator class with an array of certificates to use. More...
 
 nCertificateValidator (java.security.cert.X509Certificate[] certificates, String algorithm) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException
 Constructs the validator class with an array of certificates to use. More...
 
 nCertificateValidator (KeyStore keystore) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException, KeyStoreException
 Constructs the Validator object and loads all of the certificate found within the supplied keystore. More...
 
 nCertificateValidator (KeyStore keystore, String algorithm) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException, KeyStoreException
 Constructs the Validator object and loads all of the certificate found within the supplied keystore. More...
 
 nCertificateValidator (String keystoreName, String keyStorePasswd) throws nIllegalArgumentException, KeyStoreException, FileNotFoundException, CertificateException, NoSuchAlgorithmException, IOException, NoSuchAlgorithmException, InvalidKeyException
 Constructs a Validator object by loading the specified keystore from disk and then loading all the certificates within the keystore to be used to validate the nConsumeEvent signature. More...
 
 nCertificateValidator (String keystoreName, String keyStorePasswd, String algorithm) throws nIllegalArgumentException, KeyStoreException, FileNotFoundException, CertificateException, NoSuchAlgorithmException, IOException, NoSuchAlgorithmException, InvalidKeyException
 Constructs a Validator object by loading the specified keystore from disk and then loading all the certificates within the keystore to be used to validate the nConsumeEvent signature. More...
 
void start (byte[] sig)
 Locates the certificate that was used to create the signature. More...
 
void stop ()
 Resets this certificate that this class will use for validation.
 
void update (byte[] data) throws Exception
 Updates the signature with the supplied data. More...
 

Static Public Member Functions

static String getDefaultAlgorithm ()
 Get the default algorithm that will be used if no algorithm is supplied. More...
 

Detailed Description

This class validates signatures signed by the nCertificateSigner class.

It is constructed with at least one certificate or a list of certificates that it will then use to validate the nConsumeEvents which will be passed to the nSignedEventListener interface. The Object in the go method contains the X509 certificate of the signer. If the remote certificate can not be found then the error method is called with the signature byte[] as part of the callback

Constructor & Destructor Documentation

com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( java.security.cert.X509Certificate[]  certificates) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException

Constructs the validator class with an array of certificates to use.

Parameters
certificatesArray of X509Certificates to use
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
NoSuchAlgorithmExceptionAlgorithm can not be found
InvalidKeyExceptionUnable to access the public keys in the certificates supplied
com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( java.security.cert.X509Certificate[]  certificates,
String  algorithm 
) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException

Constructs the validator class with an array of certificates to use.

Parameters
certificatesArray of X509Certificates to use
algorithmSignature algorithm to use
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
NoSuchAlgorithmExceptionAlgorithm can not be found
InvalidKeyExceptionUnable to access the public keys in the certificates supplied
com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( KeyStore  keystore) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException, KeyStoreException

Constructs the Validator object and loads all of the certificate found within the supplied keystore.

Parameters
keystoreKeystore to use
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
NoSuchAlgorithmExceptionAlgorithm can not be found
InvalidKeyExceptionUnable to access the public keys in the certificates supplied
KeyStoreExceptionThe keystore supplied is invalid
com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( KeyStore  keystore,
String  algorithm 
) throws nIllegalArgumentException, NoSuchAlgorithmException, InvalidKeyException, KeyStoreException

Constructs the Validator object and loads all of the certificate found within the supplied keystore.

Parameters
keystoreKeystore to use
algorithmAlgorithm to use for the Signature class
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
NoSuchAlgorithmExceptionAlgorithm can not be found
InvalidKeyExceptionUnable to access the public keys in the certificates supplied
KeyStoreExceptionThe keystore supplied is invalid
com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( String  keystoreName,
String  keyStorePasswd 
) throws nIllegalArgumentException, KeyStoreException, FileNotFoundException, CertificateException, NoSuchAlgorithmException, IOException, NoSuchAlgorithmException, InvalidKeyException

Constructs a Validator object by loading the specified keystore from disk and then loading all the certificates within the keystore to be used to validate the nConsumeEvent signature.

Parameters
keystoreNameFilename of the keystore to use
keyStorePasswdPassword/phrase to use to gain access to the keystore
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
KeyStoreExceptionif KeyStore is in error
FileNotFoundExceptionKeyStore not found
CertificateExceptionInvalid Certificate
NoSuchAlgorithmExceptionAlgorithm can not be found
IOExceptionKeyStore failed during load
NoSuchAlgorithmExceptionThe algorithm specified can not be located
InvalidKeyExceptionUnable to access the public keys in the certificates supplied
com.pcbsys.nirvana.client.nCertificateValidator.nCertificateValidator ( String  keystoreName,
String  keyStorePasswd,
String  algorithm 
) throws nIllegalArgumentException, KeyStoreException, FileNotFoundException, CertificateException, NoSuchAlgorithmException, IOException, NoSuchAlgorithmException, InvalidKeyException

Constructs a Validator object by loading the specified keystore from disk and then loading all the certificates within the keystore to be used to validate the nConsumeEvent signature.

Parameters
keystoreNameFilename of the keystore to use
keyStorePasswdPassword/phrase to use to gain access to the keystore
algorithmAlgorithm to use for the Signature class
Exceptions
nIllegalArgumentExceptionIf any parameters are invalid
KeyStoreExceptionif KeyStore is in error
FileNotFoundExceptionKeyStore not found
CertificateExceptionInvalid Certificate
NoSuchAlgorithmExceptionAlgorithm can not be found
IOExceptionKeyStore failed during load
NoSuchAlgorithmExceptionThe algorithm specified can not be located
InvalidKeyExceptionUnable to access the public keys in the certificates supplied

Member Function Documentation

Object com.pcbsys.nirvana.client.nCertificateValidator.check ( byte[]  original) throws Exception

Performs the validation with the original signature against the signature created with the update methods.

Will throw an exception if the signatures do not match

Parameters
originalOriginal signature
Returns
The certificate that was used to create the signature
Exceptions
ExceptionIf the signatures do not match or unable to locate the signing certificate

Implements com.pcbsys.nirvana.client.nMessageValidator.

static String com.pcbsys.nirvana.client.nCertificateValidator.getDefaultAlgorithm ( )
static

Get the default algorithm that will be used if no algorithm is supplied.

Currently this is SHA1 with RSA.

Returns
The Algorithm name that will be used by default
java.security.cert.Certificate [] com.pcbsys.nirvana.client.nCertificateValidator.getLoadedCertificates ( )

Returns an array of certificates that this object is using to valdiate the signature.

Returns
Array of Certificate objects
Provider com.pcbsys.nirvana.client.nCertificateValidator.getProvider ( )

Return the Provider used to vend the Signature class.

Returns
a java.security.Provider class

Implements com.pcbsys.nirvana.client.nMessageValidator.

void com.pcbsys.nirvana.client.nCertificateValidator.start ( byte[]  sig)

Locates the certificate that was used to create the signature.

Then resets this object to use this certificate

Parameters
sigOriginal signing object

Implements com.pcbsys.nirvana.client.nMessageValidator.

void com.pcbsys.nirvana.client.nCertificateValidator.update ( byte[]  data) throws Exception

Updates the signature with the supplied data.

Parameters
datadata to add
Exceptions
ExceptionDepending on the implementation of the signature class

Implements com.pcbsys.nirvana.client.nMessageValidator.