pk.edu.niit.clarens.util
Class CertificateChain

java.lang.Object
  extended bypk.edu.niit.clarens.util.CertificateChain

public class CertificateChain
extends java.lang.Object

Utility class for managing a certificate chain. A chain of one element is created if there is only one certificate in the file. The first certificate in the chain is the user's certificate. The rest of the certificates form the chain of trust leading up to the CA certificate.


Constructor Summary
CertificateChain(java.io.BufferedReader inputReader)
          Load a certificate chain from an input reader.
 
Method Summary
 java.lang.String getCertChainPEM()
          Get a PEM encoded representation of the certificate chain.
 java.security.cert.Certificate[] getCertficateChain()
          Get all of the certificates in the certificate chain.
 java.security.cert.Certificate getCertificate()
          Get the first certificate from the chain.
 java.security.PublicKey getPublicKey()
          Get the public key from the user's certificate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CertificateChain

public CertificateChain(java.io.BufferedReader inputReader)
                 throws java.io.IOException,
                        java.security.cert.CertificateException
Load a certificate chain from an input reader.

Parameters:
inputReader - The input source for the certificate chain.
Throws:
java.io.IOException - Thrown for io errors.
java.security.cert.CertificateException - Thrown if there was an error creating certificates.
Method Detail

getCertificate

public java.security.cert.Certificate getCertificate()
Get the first certificate from the chain. This is the user's certificate.

Returns:
The first certificate in the chain.

getCertficateChain

public java.security.cert.Certificate[] getCertficateChain()
Get all of the certificates in the certificate chain.

Returns:
An array of certificates, starting with the user's cert.

getCertChainPEM

public java.lang.String getCertChainPEM()
Get a PEM encoded representation of the certificate chain.

Returns:
a PEM encoded string for the entire certificate chain.

getPublicKey

public java.security.PublicKey getPublicKey()
Get the public key from the user's certificate.

Returns:
The user's public key.