Class CertificateData

java.lang.Object
com.mulesoft.connectors.mcp.api.certificate.CertificateData
All Implemented Interfaces:
Serializable

public class CertificateData extends Object implements Serializable
A custom Data Transfer Object (DTO) to replace Certificate, X509Certificate, and related classes.

This class provides a comprehensive representation of a certificate with various attributes such as type, encoded form, version, subject and issuer distinguished names, serial number, validity period, public key, signature algorithm details, and extensions. It implements Serializable to allow its instances to be serialized.

See Also:
  • Constructor Details

    • CertificateData

      public CertificateData(String type, byte[] encoded)
      Constructs a new CertificateData instance with the specified type and encoded form.
      Parameters:
      type - the type of the certificate
      encoded - the encoded form of the certificate
    • CertificateData

      public CertificateData(String type, byte[] encoded, int version, PrincipalData subjectDN, PrincipalData issuerDN, BigInteger serialNumber, Date notBefore, Date notAfter, PublicKeyData publicKey, String sigAlgName, String sigAlgOID, byte[] sigAlgParams, byte[] signature, int basicConstraints, List<String> extendedKeyUsage, boolean[] keyUsage, boolean[] issuerUniqueID, List<AlternativeNameData> subjectAlternativeNames, List<AlternativeNameData> issuerAlternativeNames, List<CertificateExtension> extensions, Set<String> criticalOids, Set<String> nonCriticalOids, boolean hasUnsupportedCriticalExtensions)
      Constructs a new CertificateData instance with detailed attributes.
      Parameters:
      type - the type of the certificate
      encoded - the encoded form of the certificate
      version - the version of the certificate
      subjectDN - the subject distinguished name
      issuerDN - the issuer distinguished name
      serialNumber - the serial number of the certificate
      notBefore - the start date of the validity period
      notAfter - the end date of the validity period
      publicKey - the public key of the certificate
      sigAlgName - the signature algorithm name
      sigAlgOID - the signature algorithm OID
      sigAlgParams - the signature algorithm parameters
      signature - the signature
      basicConstraints - the basic constraints
      extendedKeyUsage - the extended key usage
      keyUsage - the key usage
      issuerUniqueID - the issuer unique ID
      subjectAlternativeNames - the subject alternative names
      issuerAlternativeNames - the issuer alternative names
      extensions - the certificate extensions
      criticalOids - the critical OIDs
      nonCriticalOids - the non-critical OIDs
      hasUnsupportedCriticalExtensions - whether the certificate has unsupported critical extensions
  • Method Details

    • getType

      public String getType()
      Returns the type of the certificate.
      Returns:
      the type of the certificate
    • getName

      public String getName()
      Returns the name of the subject distinguished name.
      Returns:
      the name of the subject distinguished name
    • getVersion

      public int getVersion()
      Returns the version of the certificate.
      Returns:
      the version of the certificate
    • getSubjectDN

      public PrincipalData getSubjectDN()
      Returns the subject distinguished name.
      Returns:
      the subject distinguished name
    • getIssuerDN

      public PrincipalData getIssuerDN()
      Returns the issuer distinguished name.
      Returns:
      the issuer distinguished name
    • getSubjectX500Principal

      public X500PrincipalData getSubjectX500Principal()
      Returns the subject X500 principal.
      Returns:
      the subject X500 principal
    • getIssuerX500Principal

      public X500PrincipalData getIssuerX500Principal()
      Returns the issuer X500 principal.
      Returns:
      the issuer X500 principal
    • getSerialNumber

      public BigInteger getSerialNumber()
      Returns the serial number of the certificate.
      Returns:
      the serial number of the certificate
    • getSerialNumberObject

      public SerialNumberData getSerialNumberObject()
      Returns the serial number as a SerialNumberData object.
      Returns:
      the serial number as a SerialNumberData object
    • getNotBefore

      public Date getNotBefore()
      Returns the start date of the validity period.
      Returns:
      the start date of the validity period
    • getNotAfter

      public Date getNotAfter()
      Returns the end date of the validity period.
      Returns:
      the end date of the validity period
    • getPublicKey

      public PublicKeyData getPublicKey()
      Returns the public key of the certificate.
      Returns:
      the public key of the certificate
    • getSigAlgName

      public String getSigAlgName()
      Returns the signature algorithm name.
      Returns:
      the signature algorithm name
    • getSigAlgOID

      public String getSigAlgOID()
      Returns the signature algorithm OID.
      Returns:
      the signature algorithm OID
    • getSigAlgParams

      public byte[] getSigAlgParams()
      Returns the signature algorithm parameters.
      Returns:
      the signature algorithm parameters
    • getSignature

      public byte[] getSignature()
      Returns the signature.
      Returns:
      the signature
    • getBasicConstraints

      public int getBasicConstraints()
      Returns the basic constraints.
      Returns:
      the basic constraints
    • getExtendedKeyUsage

      public List<String> getExtendedKeyUsage()
      Returns the extended key usage.
      Returns:
      the extended key usage
    • getKeyUsage

      public boolean[] getKeyUsage()
      Returns the key usage.
      Returns:
      the key usage
    • getSubjectAlternativeNames

      public List<AlternativeNameData> getSubjectAlternativeNames()
      Returns the subject alternative names.
      Returns:
      the subject alternative names
    • getIssuerAlternativeNames

      public List<AlternativeNameData> getIssuerAlternativeNames()
      Returns the issuer alternative names.
      Returns:
      the issuer alternative names
    • getExtensions

      public List<CertificateExtension> getExtensions()
      Returns the certificate extensions.
      Returns:
      the certificate extensions
    • getExtensionValue

      public byte[] getExtensionValue(String oid)
      Returns the value of the extension with the specified OID.
      Parameters:
      oid - the OID of the extension
      Returns:
      the value of the extension
    • getCriticalExtensionOIDs

      public Set<String> getCriticalExtensionOIDs()
      Returns the critical extension OIDs.
      Returns:
      the critical extension OIDs
    • getNonCriticalExtensionOIDs

      public Set<String> getNonCriticalExtensionOIDs()
      Returns the non-critical extension OIDs.
      Returns:
      the non-critical extension OIDs
    • hasUnsupportedCriticalExtension

      public boolean hasUnsupportedCriticalExtension()
      Returns whether the certificate has unsupported critical extensions.
      Returns:
      true if the certificate has unsupported critical extensions; false otherwise
    • getIssuerUniqueID

      public boolean[] getIssuerUniqueID()
      Returns the issuer unique ID.
      Returns:
      the issuer unique ID
    • checkValidity

      public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException
      Checks if the certificate is currently valid.
      Throws:
      CertificateExpiredException - if the certificate has expired
      CertificateNotYetValidException - if the certificate is not yet valid
    • checkValidity

      public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException
      Checks if the certificate is valid at the specified date.
      Parameters:
      date - the date to check the validity against
      Throws:
      CertificateExpiredException - if the certificate has expired
      CertificateNotYetValidException - if the certificate is not yet valid
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • formatSignature

      public static String formatSignature(byte[] signature)
      Formats the signature bytes into a readable string representation.
      Parameters:
      signature - the signature bytes
      Returns:
      a formatted string representation of the signature
    • getEncoded

      public byte[] getEncoded() throws CertificateEncodingException
      Returns the encoded form of the certificate.
      Returns:
      the encoded form of the certificate
      Throws:
      CertificateEncodingException - if encoding fails