Package org.bouncycastle.cert.c509
Class C509CertificateHolder
- java.lang.Object
-
- org.bouncycastle.cert.c509.C509CertificateHolder
-
- All Implemented Interfaces:
org.bouncycastle.util.Encodable
public class C509CertificateHolder extends java.lang.Object implements org.bouncycastle.util.EncodableHolding class for a C509 certificate (draft-ietf-cose-cbor-encoded-cert-20), mirroringX509CertificateHolder.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 anX509CertificateHolderwithtoX509CertificateHolder().
-
-
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 booleanequals(java.lang.Object o)org.bouncycastle.cbor.c509.C509CertificategetC509Certificate()Return the certificate this holder wraps.intgetCertificateType()Return the certificate type (C509Certificate.TYPE_NATIVEorC509Certificate.TYPE_REENCODED_X509).byte[]getEncoded()Return the CBOR encoding of the certificate.org.bouncycastle.asn1.x509.ExtensionsgetExtensions()Return the X.509 view of the extensions, or null if there are none.org.bouncycastle.asn1.x500.X500NamegetIssuer()java.util.DategetNotAfter()Return the end of the validity period.java.util.DategetNotBefore()java.math.BigIntegergetSerialNumber()org.bouncycastle.cbor.c509.C509AlgorithmIdentifiergetSignatureAlgorithm()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.X500NamegetSubject()org.bouncycastle.asn1.x509.SubjectPublicKeyInfogetSubjectPublicKeyInfo()inthashCode()booleanisSignatureValid(ContentVerifierProvider verifierProvider)Validate the signature on this certificate.booleanisValidOn(java.util.Date date)Return whether or not the certificate is valid on the date given.X509CertificateHoldertoX509CertificateHolder()Return the X.509 holder for a CBOR re-encoded (type 3) certificate.
-
-
-
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.IOExceptionCreate 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_NATIVEorC509Certificate.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.IOExceptionReturn 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.IOExceptionReturn the CBOR encoding of the certificate.- Specified by:
getEncodedin interfaceorg.bouncycastle.util.Encodable- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-