Class C509CertificateHolder

java.lang.Object
org.bouncycastle.cert.c509.C509CertificateHolder
All Implemented Interfaces:
org.bouncycastle.util.Encodable

public class C509CertificateHolder extends 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(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 Details

    • C509CertificateHolder

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

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

    • 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 BigInteger getSerialNumber()
    • getIssuer

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

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

      public Date getNotBefore()
    • getNotAfter

      public 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(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 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:
      IOException
    • toX509CertificateHolder

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

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object