Class CertificateToken

All Implemented Interfaces:
IdentifierBasedObject, Serializable

public class CertificateToken extends Token
Whenever the signature validation process encounters an X509Certificate a certificateToken is created.
This class encapsulates some frequently used information: a certificate comes from a certain context (Trusted List, CertStore, Signature), has revocation data... To expedite the processing of such information, they are kept in cache.
See Also:
  • Constructor Details

    • CertificateToken

      public CertificateToken(X509Certificate x509Certificate)
      Creates a CertificateToken wrapping the provided X509Certificate.
      x509Certificate - the X509Certificate object
  • Method Details

    • getAbbreviation

      public String getAbbreviation()
      Description copied from class: Token
      This method returns the DSS abbreviation of the token. It is used for debugging purpose.
      getAbbreviation in class Token
      an abbreviation for the certificate
    • getEntityKey

      public EntityIdentifier getEntityKey()
      Returns the identifier of the current public key. Several certificate can have the same public key (cross-certificates)
    • getPublicKey

      public PublicKey getPublicKey()
      Returns the public key associated with the certificate.
      To get the encryption algorithm used with this public key call getAlgorithm() method.
      RFC 2459: Subject Public Key Info This field is used to carry the public key and identify the algorithm with which the key is used. The algorithm is identified using the AlgorithmIdentifier structure specified in section The object identifiers for the supported algorithms and the methods for encoding the public key materials (public key and parameters) are specified in section 7.3.
      the public key of the certificate
    • getNotAfter

      public Date getNotAfter()
      Returns the expiration date of the certificate.
      the expiration date (notAfter)
    • getNotBefore

      public Date getNotBefore()
      Returns the issuance date of the certificate.
      the issuance date (notBefore)
    • getCreationDate

      public Date getCreationDate()
      Description copied from class: Token
      Returns the creation date of this token. This date is mainly used to retrieve the correct issuer within a collection of renewed certificates (new certificate with the same key pair).
      Specified by:
      getCreationDate in class Token
      the creation date of the token (notBefore for a certificate, productionDate for revocation data,...)
    • isValidOn

      public boolean isValidOn(Date date)
      Checks if the given date is in the validity period of the certificate.
      date - the date to be tested
      true if the given date is in the certificate period validity
    • isSelfSigned

      public boolean isSelfSigned()
      Checks if the certificate is self-signed. "Self-signed certificates are self-issued certificates where the digital signature may be verified by the public key bound into the certificate. Self-signed certificates are used to convey a public key for use to begin certification paths." [RFC5280]
      isSelfSigned in class Token
      true if the certificate is a self-sign
    • isSelfIssued

      public boolean isSelfIssued()
      This method returns true if the certificate is self-issued. "Self-issued certificates are CA certificates in which the issuer and subject are the same entity. Self-issued certificates are generated to support changes in policy or operations." [RFC5280]
      true if the certificate is self-issued
    • isEquivalent

      public boolean isEquivalent(CertificateToken token)
      This method returns true if the given token is equivalent.
      token - the token to be compared
      true if the given certificate has the same public key
    • getCertificate

      public X509Certificate getCertificate()
      Gets the enclosed X509 Certificate.
      the X509Certificate object
    • getEncoded

      public byte[] getEncoded()
      Returns the encoded form of this certificate. X.509 certificates would be encoded as ASN.1 DER.
      Specified by:
      getEncoded in class Token
      the encoded form of this certificate
    • getSerialNumber

      public BigInteger getSerialNumber()
      Gets the serialNumber value from the encapsulated certificate. The serial number is an integer assigned by the certification authority to each certificate. It must be unique for each certificate issued by a given CA.
      the certificate serial number
    • getSubject

      public X500PrincipalHelper getSubject()
      Returns the subject as wrapped X500Principal with helpful methods
      an instance of X500PrincipalHelper with the SubjectX500Principal
    • getIssuer

      public X500PrincipalHelper getIssuer()
      Returns the issuer as wrapped X500Principal with helpful methods
      an instance of X500PrincipalHelper with the IssuerX500Principal
    • getIssuerX500Principal

      public X500Principal getIssuerX500Principal()
      Returns the X500Principal of the certificate which was used to sign this token.
      Specified by:
      getIssuerX500Principal in class Token
      the issuer's X500Principal
    • checkIsSignedBy

      protected SignatureValidity checkIsSignedBy(PublicKey publicKey)
      Description copied from class: Token
      Verifies if the current token has been signed by the specified publicKey
      Specified by:
      checkIsSignedBy in class Token
      publicKey - PublicKey of a signing candidate
    • checkKeyUsage

      public boolean checkKeyUsage(KeyUsageBit keyUsageBit)
      This method checks if the certificate contains the given key usage bit.
      keyUsageBit - the keyUsageBit to be checked.
      true if contains
    • getKeyUsageBits

      public List<KeyUsageBit> getKeyUsageBits()
      This method returns a list KeyUsageBit representing the key usages of the certificate.
      List of KeyUsageBits of different certificate's key usages
    • isCA

      public boolean isCA()
      This method checks if the BasicConstraint is present
      true if the certificate is defined as a CA
    • getSignature

      public byte[] getSignature()
      The signature value of the certificate
      the signature value
    • buildTokenIdentifier

      protected TokenIdentifier buildTokenIdentifier()
      Description copied from class: Token
      Builds a token unique identifier
      Specified by:
      buildTokenIdentifier in class Token
    • toString

      public String toString(String indentStr)
      Description copied from class: Token
      Returns a string representation of the token.
      Specified by:
      toString in class Token
      indentStr - the indentation to use
      string representation of the token