Class C509CertificateHolder

  • All Implemented Interfaces:
    org.bouncycastle.util.Encodable

    public class C509CertificateHolder
    extends java.lang.Object
    implements org.bouncycastle.util.Encodable
    Holding class for a C509 certificate (draft-ietf-cose-cbor-encoded-cert-20), mirroring X509CertificateHolder.

    For a natively signed certificate (type 2) the signature covers the TBSCertificate CBOR sequence and isSignatureValid(org.bouncycastle.operator.ContentVerifierProvider) checks it directly over those bytes. For a CBOR re-encoded X.509 certificate (type 3) the signature covers the reconstructed DER TBSCertificate, and the holder can also be turned back into an X509CertificateHolder with toX509CertificateHolder().

    • Constructor Summary

      Constructors 
      Constructor Description
      C509CertificateHolder​(byte[] encoding)
      Create a holder from the CBOR encoding of a C509 certificate.
      C509CertificateHolder​(org.bouncycastle.cbor.c509.C509Certificate certificate)
      Base constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      org.bouncycastle.cbor.c509.C509Certificate getC509Certificate()
      Return the certificate this holder wraps.
      int getCertificateType()
      Return the certificate type (C509Certificate.TYPE_NATIVE or C509Certificate.TYPE_REENCODED_X509).
      byte[] getEncoded()
      Return the CBOR encoding of the certificate.
      org.bouncycastle.asn1.x509.Extensions getExtensions()
      Return the X.509 view of the extensions, or null if there are none.
      org.bouncycastle.asn1.x500.X500Name getIssuer()  
      java.util.Date getNotAfter()
      Return the end of the validity period.
      java.util.Date getNotBefore()  
      java.math.BigInteger getSerialNumber()  
      org.bouncycastle.cbor.c509.C509AlgorithmIdentifier getSignatureAlgorithm()  
      byte[] getSignedBytes()
      Return the bytes the certificate signature is computed over: the TBSCertificate CBOR sequence for a natively signed certificate, the reconstructed DER TBSCertificate for a re-encoded one.
      org.bouncycastle.asn1.x500.X500Name getSubject()  
      org.bouncycastle.asn1.x509.SubjectPublicKeyInfo getSubjectPublicKeyInfo()  
      int hashCode()  
      boolean isSignatureValid​(ContentVerifierProvider verifierProvider)
      Validate the signature on this certificate.
      boolean isValidOn​(java.util.Date date)
      Return whether or not the certificate is valid on the date given.
      X509CertificateHolder toX509CertificateHolder()
      Return the X.509 holder for a CBOR re-encoded (type 3) certificate.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • C509CertificateHolder

        public C509CertificateHolder​(org.bouncycastle.cbor.c509.C509Certificate certificate)
        Base constructor.
        Parameters:
        certificate - the certificate this holder wraps.
      • C509CertificateHolder

        public C509CertificateHolder​(byte[] encoding)
                              throws java.io.IOException
        Create a holder from the CBOR encoding of a C509 certificate.
        Throws:
        java.io.IOException
    • Method Detail

      • getC509Certificate

        public org.bouncycastle.cbor.c509.C509Certificate getC509Certificate()
        Return the certificate this holder wraps.
      • getCertificateType

        public int getCertificateType()
        Return the certificate type (C509Certificate.TYPE_NATIVE or C509Certificate.TYPE_REENCODED_X509).
      • getSerialNumber

        public java.math.BigInteger getSerialNumber()
      • getIssuer

        public org.bouncycastle.asn1.x500.X500Name getIssuer()
      • getSubject

        public org.bouncycastle.asn1.x500.X500Name getSubject()
      • getNotBefore

        public java.util.Date getNotBefore()
      • getNotAfter

        public java.util.Date getNotAfter()
        Return the end of the validity period. A certificate with no well-defined expiration date (99991231235959Z) returns the corresponding date.
      • isValidOn

        public boolean isValidOn​(java.util.Date date)
        Return whether or not the certificate is valid on the date given.
      • getSubjectPublicKeyInfo

        public org.bouncycastle.asn1.x509.SubjectPublicKeyInfo getSubjectPublicKeyInfo()
      • getSignatureAlgorithm

        public org.bouncycastle.cbor.c509.C509AlgorithmIdentifier getSignatureAlgorithm()
      • getExtensions

        public org.bouncycastle.asn1.x509.Extensions getExtensions()
        Return the X.509 view of the extensions, or null if there are none.
      • isSignatureValid

        public boolean isSignatureValid​(ContentVerifierProvider verifierProvider)
                                 throws CertException
        Validate the signature on this certificate.
        Parameters:
        verifierProvider - a provider of verifiers built on the issuer's public key.
        Returns:
        true if the signature verifies, false otherwise.
        Throws:
        CertException
      • getSignedBytes

        public byte[] getSignedBytes()
                              throws java.io.IOException
        Return the bytes the certificate signature is computed over: the TBSCertificate CBOR sequence for a natively signed certificate, the reconstructed DER TBSCertificate for a re-encoded one.
        Throws:
        java.io.IOException
      • toX509CertificateHolder

        public X509CertificateHolder toX509CertificateHolder()
                                                      throws java.io.IOException
        Return the X.509 holder for a CBOR re-encoded (type 3) certificate.
        Throws:
        java.lang.IllegalStateException - if this is a natively signed certificate.
        java.io.IOException
      • getEncoded

        public byte[] getEncoded()
                          throws java.io.IOException
        Return the CBOR encoding of the certificate.
        Specified by:
        getEncoded in interface org.bouncycastle.util.Encodable
        Throws:
        java.io.IOException
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object