org.nhindirect.stagent.cert
Class X509CertificateEx

java.lang.Object
  extended by java.security.cert.Certificate
      extended by java.security.cert.X509Certificate
          extended by org.nhindirect.stagent.cert.X509CertificateEx
All Implemented Interfaces:
Serializable, X509Extension

public class X509CertificateEx
extends X509Certificate

Extended X509 certificate that contains private key information.

Author:
Greg Meyer
See Also:
Serialized Form

Method Summary
 void checkValidity()
           
 void checkValidity(Date date)
           
 boolean equals(Object other)
           
static X509CertificateEx fromX509Certificate(X509Certificate cert, PrivateKey privKey)
          Creates X509CertificateEx object from an existing certificate and its private key.
 int getBasicConstraints()
           
 Set<String> getCriticalExtensionOIDs()
          
 byte[] getEncoded()
           
 List<String> getExtendedKeyUsage()
           
 byte[] getExtensionValue(String oid)
          
 Collection<List<?>> getIssuerAlternativeNames()
           
 Principal getIssuerDN()
           
 boolean[] getIssuerUniqueID()
           
 X500Principal getIssuerX500Principal()
           
 boolean[] getKeyUsage()
           
 Set<String> getNonCriticalExtensionOIDs()
          
 Date getNotAfter()
           
 Date getNotBefore()
           
 PrivateKey getPrivateKey()
          Gets the certificates private key.
 PublicKey getPublicKey()
           
 BigInteger getSerialNumber()
           
 String getSigAlgName()
           
 String getSigAlgOID()
           
 byte[] getSigAlgParams()
           
 byte[] getSignature()
           
 Collection<List<?>> getSubjectAlternativeNames()
           
 Principal getSubjectDN()
           
 boolean[] getSubjectUniqueID()
           
 X500Principal getSubjectX500Principal()
           
 byte[] getTBSCertificate()
           
 int getVersion()
           
 int hashCode()
           
 boolean hasPrivateKey()
          Indicates if the certificate contains its private key.
 boolean hasUnsupportedCriticalExtension()
          
 String toString()
           
 void verify(PublicKey key)
           
 void verify(PublicKey key, String sigProvider)
           
 
Methods inherited from class java.security.cert.Certificate
getType
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

fromX509Certificate

public static X509CertificateEx fromX509Certificate(X509Certificate cert,
                                                    PrivateKey privKey)
Creates X509CertificateEx object from an existing certificate and its private key.

Parameters:
cert - The original certificate.
privKey - The certificates private key.
Returns:
A certificate wrapper that contains the original certificates and its private key.

checkValidity

public void checkValidity()
                   throws CertificateExpiredException,
                          CertificateNotYetValidException
Specified by:
checkValidity in class X509Certificate
Throws:
CertificateExpiredException
CertificateNotYetValidException

checkValidity

public void checkValidity(Date date)
                   throws CertificateExpiredException,
                          CertificateNotYetValidException
Specified by:
checkValidity in class X509Certificate
Throws:
CertificateExpiredException
CertificateNotYetValidException

getBasicConstraints

public int getBasicConstraints()
Specified by:
getBasicConstraints in class X509Certificate

getExtendedKeyUsage

public List<String> getExtendedKeyUsage()
                                 throws CertificateParsingException
Overrides:
getExtendedKeyUsage in class X509Certificate
Throws:
CertificateParsingException

getIssuerAlternativeNames

public Collection<List<?>> getIssuerAlternativeNames()
                                              throws CertificateParsingException
Overrides:
getIssuerAlternativeNames in class X509Certificate
Throws:
CertificateParsingException

getIssuerDN

public Principal getIssuerDN()
Specified by:
getIssuerDN in class X509Certificate

getIssuerUniqueID

public boolean[] getIssuerUniqueID()
Specified by:
getIssuerUniqueID in class X509Certificate

getIssuerX500Principal

public X500Principal getIssuerX500Principal()
Overrides:
getIssuerX500Principal in class X509Certificate

getKeyUsage

public boolean[] getKeyUsage()
Specified by:
getKeyUsage in class X509Certificate

getNotAfter

public Date getNotAfter()
Specified by:
getNotAfter in class X509Certificate

getNotBefore

public Date getNotBefore()
Specified by:
getNotBefore in class X509Certificate

getSerialNumber

public BigInteger getSerialNumber()
Specified by:
getSerialNumber in class X509Certificate

getSigAlgName

public String getSigAlgName()
Specified by:
getSigAlgName in class X509Certificate

getSigAlgOID

public String getSigAlgOID()
Specified by:
getSigAlgOID in class X509Certificate

getSigAlgParams

public byte[] getSigAlgParams()
Specified by:
getSigAlgParams in class X509Certificate

getSignature

public byte[] getSignature()
Specified by:
getSignature in class X509Certificate

getSubjectAlternativeNames

public Collection<List<?>> getSubjectAlternativeNames()
                                               throws CertificateParsingException
Overrides:
getSubjectAlternativeNames in class X509Certificate
Throws:
CertificateParsingException

getSubjectDN

public Principal getSubjectDN()
Specified by:
getSubjectDN in class X509Certificate

getSubjectUniqueID

public boolean[] getSubjectUniqueID()
Specified by:
getSubjectUniqueID in class X509Certificate

getSubjectX500Principal

public X500Principal getSubjectX500Principal()
Overrides:
getSubjectX500Principal in class X509Certificate

getTBSCertificate

public byte[] getTBSCertificate()
                         throws CertificateEncodingException
Specified by:
getTBSCertificate in class X509Certificate
Throws:
CertificateEncodingException

getVersion

public int getVersion()
Specified by:
getVersion in class X509Certificate

equals

public boolean equals(Object other)
Overrides:
equals in class Certificate

getEncoded

public byte[] getEncoded()
                  throws CertificateEncodingException
Specified by:
getEncoded in class Certificate
Throws:
CertificateEncodingException

getPublicKey

public PublicKey getPublicKey()
Specified by:
getPublicKey in class Certificate

hashCode

public int hashCode()
Overrides:
hashCode in class Certificate

toString

public String toString()
Specified by:
toString in class Certificate

verify

public void verify(PublicKey key)
            throws CertificateException,
                   NoSuchAlgorithmException,
                   InvalidKeyException,
                   NoSuchProviderException,
                   SignatureException
Specified by:
verify in class Certificate
Throws:
CertificateException
NoSuchAlgorithmException
InvalidKeyException
NoSuchProviderException
SignatureException

verify

public void verify(PublicKey key,
                   String sigProvider)
            throws CertificateException,
                   NoSuchAlgorithmException,
                   InvalidKeyException,
                   NoSuchProviderException,
                   SignatureException
Specified by:
verify in class Certificate
Throws:
CertificateException
NoSuchAlgorithmException
InvalidKeyException
NoSuchProviderException
SignatureException

hasUnsupportedCriticalExtension

public boolean hasUnsupportedCriticalExtension()


getCriticalExtensionOIDs

public Set<String> getCriticalExtensionOIDs()


getNonCriticalExtensionOIDs

public Set<String> getNonCriticalExtensionOIDs()


getExtensionValue

public byte[] getExtensionValue(String oid)


hasPrivateKey

public boolean hasPrivateKey()
Indicates if the certificate contains its private key.

Returns:
True if the certificate has access to its private key. False otherwise.

getPrivateKey

public PrivateKey getPrivateKey()
Gets the certificates private key.

Returns:
Gets the certificates private key.


Copyright © 2010-2015 NHIN Direct. All Rights Reserved.