Class CertificateChain

  • All Implemented Interfaces:
    java.io.Serializable

    public class CertificateChain
    extends java.lang.Object
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CertificateChain()
      Constructs an empty certificate chain.
      CertificateChain​(java.security.cert.X509Certificate cert)
      constructs a certificate chain from a certificate.
      CertificateChain​(java.security.cert.X509Certificate[] certs)
      constructs a certificate chain from a X509 certificate array.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void decode​(java.io.InputStream in)
      decode from PKCS7 blob.
      void encode​(java.io.OutputStream out)  
      void encode​(java.io.OutputStream out, boolean sort)
      encode in PKCS7 blob.
      java.security.cert.X509Certificate getCertificate​(int index)
      returns the certificate at specified index in chain.
      java.util.List<java.security.cert.X509Certificate> getCertificates()
      Returns the certificate list.
      java.security.cert.X509Certificate[] getChain()
      returns the certificate chain as an array of X509 certificates.
      java.security.cert.X509Certificate getFirstCertificate()
      returns the first certificate in chain.
      void sort()
      Sorts certificate chain from root to leaf.
      java.lang.String toString()
      Converts the certificate chain to a readable string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CertificateChain

        public CertificateChain()
        Constructs an empty certificate chain.
      • CertificateChain

        public CertificateChain​(java.security.cert.X509Certificate cert)
        constructs a certificate chain from a certificate.
        Parameters:
        cert - a certificate
      • CertificateChain

        public CertificateChain​(java.security.cert.X509Certificate[] certs)
        constructs a certificate chain from a X509 certificate array.
        Parameters:
        certs - a certificate array.
    • Method Detail

      • getCertificates

        public java.util.List<java.security.cert.X509Certificate> getCertificates()
        Returns the certificate list.
        Returns:
        The certificate list.
      • getCertificate

        public java.security.cert.X509Certificate getCertificate​(int index)
        returns the certificate at specified index in chain.
        Parameters:
        index - the index.
        Returns:
        the X509 certificate at the given index.
      • getFirstCertificate

        public java.security.cert.X509Certificate getFirstCertificate()
        returns the first certificate in chain.
        Returns:
        the X509 certificate at the given index.
      • getChain

        public java.security.cert.X509Certificate[] getChain()
        returns the certificate chain as an array of X509 certificates.
        Returns:
        an array of X509 Certificates.
      • sort

        public void sort()
                  throws java.lang.Exception
        Sorts certificate chain from root to leaf.
        Throws:
        java.lang.Exception
      • encode

        public void encode​(java.io.OutputStream out)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • encode

        public void encode​(java.io.OutputStream out,
                           boolean sort)
                    throws java.io.IOException
        encode in PKCS7 blob.
        Throws:
        java.io.IOException
      • decode

        public void decode​(java.io.InputStream in)
                    throws java.io.IOException
        decode from PKCS7 blob.
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Converts the certificate chain to a readable string.
        Overrides:
        toString in class java.lang.Object