Module jpms_dss_spi

Class CommonCertificateSource

java.lang.Object
eu.europa.esig.dss.spi.x509.CommonCertificateSource
All Implemented Interfaces:
CertificateSource, Serializable
Direct Known Subclasses:
CommonTrustedCertificateSource, KeyStoreCertificateSource, TokenCertificateSource

public class CommonCertificateSource extends Object implements CertificateSource
This class is the common class for all CertificateSource. It stores added certificates and allows to retrieve them with several methods
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    This object is used to match CertificateTokens and CertificateRefs
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    eu.europa.esig.dss.model.x509.CertificateToken
    addCertificate(eu.europa.esig.dss.model.x509.CertificateToken certificateToAdd)
    This method adds an external certificate to the source.
    protected boolean
    doesCertificateReferenceMatch(eu.europa.esig.dss.model.x509.CertificateToken certificateToken, CertificateRef certificateRef)
    This method verifies whether the CertificateRef does match to the CertificateToken
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    Returns Set of CertificateTokens for the provided CertificateRef
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    getByCertificateDigest(eu.europa.esig.dss.model.Digest digest)
    This method returns the Set of certificates with the Digest
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    This method returns a list of CertificateToken with the given PublicKey
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    This method returns the Set of certificates with the CertificateIdentifier
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    getBySki(byte[] ski)
    This method returns a list of CertificateToken with the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))
    Set<eu.europa.esig.dss.model.x509.CertificateToken>
    getBySubject(eu.europa.esig.dss.model.x509.X500PrincipalHelper subject)
    This method returns the Set of certificates with the same subjectDN.
    List<eu.europa.esig.dss.model.x509.CertificateToken>
    Retrieves the unmodifiable list of all certificate tokens from this source.
    eu.europa.esig.dss.enumerations.CertificateSourceType
    This method returns the certificate source type associated to the implementation class.
    List<eu.europa.esig.dss.spi.x509.CertificateSourceEntity>
    Returns a list of certificates grouped by their public keys
    int
    This method returns the number of stored certificates in this source
    int
    This method returns the number of stored entities (unique public key) in this source
    boolean
    This method checks if all certificates are self-signed
    boolean
    This method checks if the current and the given CertificateSources contain the same certificate tokens
    boolean
    This method checks if the current and the given CertificateSources contain the same public keys
    boolean
    isKnown(eu.europa.esig.dss.model.x509.CertificateToken token)
    This method checks if a given certificate is known in the current source
    boolean
    isTrusted(eu.europa.esig.dss.model.x509.CertificateToken certificateToken)
    This method checks if a given certificate is trusted
    protected void
    removeCertificate(eu.europa.esig.dss.model.x509.CertificateToken certificateToRemove)
    This method removes the corresponding certificate token from the certificate source
    protected void
    This method removes all certificates from the source

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • certificateMatcher

      protected final transient CertificateTokenRefMatcher certificateMatcher
      This object is used to match CertificateTokens and CertificateRefs
  • Constructor Details

    • CommonCertificateSource

      public CommonCertificateSource()
      The default constructor
  • Method Details

    • addCertificate

      public eu.europa.esig.dss.model.x509.CertificateToken addCertificate(eu.europa.esig.dss.model.x509.CertificateToken certificateToAdd)
      This method adds an external certificate to the source. If the public is already known, the certificate is merged in the CertificateSourceEntity
      Specified by:
      addCertificate in interface CertificateSource
      Parameters:
      certificateToAdd - the certificate to be added
      Returns:
      the corresponding certificate token
    • removeCertificate

      protected void removeCertificate(eu.europa.esig.dss.model.x509.CertificateToken certificateToRemove)
      This method removes the corresponding certificate token from the certificate source
      Parameters:
      certificateToRemove - CertificateToken to remove
    • reset

      protected void reset()
      This method removes all certificates from the source
    • isKnown

      public boolean isKnown(eu.europa.esig.dss.model.x509.CertificateToken token)
      Description copied from interface: CertificateSource
      This method checks if a given certificate is known in the current source
      Specified by:
      isKnown in interface CertificateSource
      Parameters:
      token - the certificate to be tested
      Returns:
      true if the certificate is part of the current source
    • getCertificates

      public List<eu.europa.esig.dss.model.x509.CertificateToken> getCertificates()
      Retrieves the unmodifiable list of all certificate tokens from this source.
      Specified by:
      getCertificates in interface CertificateSource
      Returns:
      all certificates from this source
    • getEntities

      public List<eu.europa.esig.dss.spi.x509.CertificateSourceEntity> getEntities()
      Description copied from interface: CertificateSource
      Returns a list of certificates grouped by their public keys
      Specified by:
      getEntities in interface CertificateSource
      Returns:
      a list of CertificateSourceEntitys
    • getByPublicKey

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> getByPublicKey(PublicKey publicKey)
      This method returns a list of CertificateToken with the given PublicKey
      Specified by:
      getByPublicKey in interface CertificateSource
      Parameters:
      publicKey - the public key to find
      Returns:
      a list of CertificateToken which have the given public key
    • getBySki

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> getBySki(byte[] ski)
      This method returns a list of CertificateToken with the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))
      Specified by:
      getBySki in interface CertificateSource
      Parameters:
      ski - the Subject Key Identifier
      Returns:
      a list of CertificateToken which have the given ski
    • getBySubject

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> getBySubject(eu.europa.esig.dss.model.x509.X500PrincipalHelper subject)
      This method returns the Set of certificates with the same subjectDN.
      Specified by:
      getBySubject in interface CertificateSource
      Parameters:
      subject - the subject to match
      Returns:
      If no match is found then an empty list is returned.
    • getBySignerIdentifier

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> getBySignerIdentifier(SignerIdentifier signerIdentifier)
      Description copied from interface: CertificateSource
      This method returns the Set of certificates with the CertificateIdentifier
      Specified by:
      getBySignerIdentifier in interface CertificateSource
      Parameters:
      signerIdentifier - the certificate identifier to match
      Returns:
      If no match is found then an empty set is returned.
    • getByCertificateDigest

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> getByCertificateDigest(eu.europa.esig.dss.model.Digest digest)
      Description copied from interface: CertificateSource
      This method returns the Set of certificates with the Digest
      Specified by:
      getByCertificateDigest in interface CertificateSource
      Parameters:
      digest - the certificate digest to be found
      Returns:
      the found certificates or an empty Set
    • findTokensFromCertRef

      public Set<eu.europa.esig.dss.model.x509.CertificateToken> findTokensFromCertRef(CertificateRef certificateRef)
      Description copied from interface: CertificateSource
      Returns Set of CertificateTokens for the provided CertificateRef
      Specified by:
      findTokensFromCertRef in interface CertificateSource
      Parameters:
      certificateRef - a CertificateRef
      Returns:
      Set of CertificateTokens
    • doesCertificateReferenceMatch

      protected boolean doesCertificateReferenceMatch(eu.europa.esig.dss.model.x509.CertificateToken certificateToken, CertificateRef certificateRef)
      This method verifies whether the CertificateRef does match to the CertificateToken
      Parameters:
      certificateToken - CertificateToken to be verified
      certificateRef - CertificateRef to be used to
      Returns:
      TRUE if the certificate reference matches the certificate token, FALSE otherwise
    • getNumberOfCertificates

      public int getNumberOfCertificates()
      This method returns the number of stored certificates in this source
      Returns:
      number of certificates in this instance
    • getNumberOfEntities

      public int getNumberOfEntities()
      This method returns the number of stored entities (unique public key) in this source
      Returns:
      number of entities in this instance
    • getCertificateSourceType

      public eu.europa.esig.dss.enumerations.CertificateSourceType getCertificateSourceType()
      Description copied from interface: CertificateSource
      This method returns the certificate source type associated to the implementation class.
      Specified by:
      getCertificateSourceType in interface CertificateSource
      Returns:
      the certificate origin
    • isTrusted

      public boolean isTrusted(eu.europa.esig.dss.model.x509.CertificateToken certificateToken)
      Description copied from interface: CertificateSource
      This method checks if a given certificate is trusted
      Specified by:
      isTrusted in interface CertificateSource
      Parameters:
      certificateToken - the certificate to be tested
      Returns:
      true if the certificate is trusted
    • isAllSelfSigned

      public boolean isAllSelfSigned()
      Description copied from interface: CertificateSource
      This method checks if all certificates are self-signed
      Specified by:
      isAllSelfSigned in interface CertificateSource
      Returns:
      true if all certificates are self-signed
    • isCertificateSourceEqual

      public boolean isCertificateSourceEqual(CertificateSource certificateSource)
      Description copied from interface: CertificateSource
      This method checks if the current and the given CertificateSources contain the same certificate tokens
      Specified by:
      isCertificateSourceEqual in interface CertificateSource
      Parameters:
      certificateSource - CertificateSource to compare
      Returns:
      TRUE if both certificate sources contains the same certificate tokens, FALSE otherwise
    • isCertificateSourceEquivalent

      public boolean isCertificateSourceEquivalent(CertificateSource certificateSource)
      Description copied from interface: CertificateSource
      This method checks if the current and the given CertificateSources contain the same public keys
      Specified by:
      isCertificateSourceEquivalent in interface CertificateSource
      Parameters:
      certificateSource - CertificateSource to compare
      Returns:
      TRUE if both certificate sources contains the same public keys, FALSE otherwise