Package eu.europa.esig.dss.spi.x509
Class CommonCertificateSource
java.lang.Object
eu.europa.esig.dss.spi.x509.CommonCertificateSource
- All Implemented Interfaces:
CertificateSource,Serializable
- Direct Known Subclasses:
AIACertificateSource,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:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description CommonCertificateSource()The default constructor -
Method Summary
Modifier and Type Method Description CertificateTokenaddCertificate(CertificateToken certificateToAdd)This method adds an external certificate to the source.Set<CertificateToken>getByCertificateIdentifier(CertificateIdentifier certificateIdentifier)This method returns the Set of certificates with theCertificateIdentifierSet<CertificateToken>getByPublicKey(PublicKey publicKey)This method returns a list ofCertificateTokenwith the givenPublicKeySet<CertificateToken>getBySki(byte[] ski)This method returns a list ofCertificateTokenwith the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))Set<CertificateToken>getBySubject(X500PrincipalHelper subject)This method returns the Set of certificates with the same subjectDN.List<CertificateToken>getCertificates()Retrieves the unmodifiable list of all certificate tokens from this source.CertificateSourceTypegetCertificateSourceType()This method returns the certificate source type associated to the implementation class.List<eu.europa.esig.dss.spi.x509.CertificateSourceEntity>getEntities()intgetNumberOfCertificates()This method returns the number of stored certificates in this sourceintgetNumberOfEntities()This method returns the number of stored entities (unique public key) in this sourcebooleanisAllSelfSigned()This method checks if all certificates are self-signedbooleanisKnown(CertificateToken token)This method checks if a given certificate is known in the current sourcebooleanisTrusted(CertificateToken certificateToken)This method checks if a given certificate is trustedprotected voidreset()
-
Constructor Details
-
CommonCertificateSource
public CommonCertificateSource()The default constructor
-
-
Method Details
-
addCertificate
This method adds an external certificate to the source. If the public is already known, the certificate is merged in theCertificateSourceEntity- Specified by:
addCertificatein interfaceCertificateSource- Parameters:
certificateToAdd- the certificate to be added- Returns:
- the corresponding certificate token
-
reset
protected void reset() -
isKnown
Description copied from interface:CertificateSourceThis method checks if a given certificate is known in the current source- Specified by:
isKnownin interfaceCertificateSource- Parameters:
token- the certificate to be tested- Returns:
- true if the certificate is part of the current source
-
getCertificates
Retrieves the unmodifiable list of all certificate tokens from this source.- Specified by:
getCertificatesin interfaceCertificateSource- Returns:
- all certificates from this source
-
getEntities
- Specified by:
getEntitiesin interfaceCertificateSource
-
getByPublicKey
This method returns a list ofCertificateTokenwith the givenPublicKey- Specified by:
getByPublicKeyin interfaceCertificateSource- Parameters:
publicKey- the public key to find- Returns:
- a list of CertificateToken which have the given public key
-
getBySki
This method returns a list ofCertificateTokenwith the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))- Specified by:
getBySkiin interfaceCertificateSource- Parameters:
ski- the Subject Key Identifier- Returns:
- a list of CertificateToken which have the given ski
-
getBySubject
This method returns the Set of certificates with the same subjectDN.- Specified by:
getBySubjectin interfaceCertificateSource- Parameters:
subject- the subject to match- Returns:
- If no match is found then an empty list is returned.
-
getByCertificateIdentifier
public Set<CertificateToken> getByCertificateIdentifier(CertificateIdentifier certificateIdentifier)Description copied from interface:CertificateSourceThis method returns the Set of certificates with theCertificateIdentifier- Specified by:
getByCertificateIdentifierin interfaceCertificateSource- Parameters:
certificateIdentifier- the certificate identifier to match- Returns:
- If no match is found then an empty set is returned.
-
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
Description copied from interface:CertificateSourceThis method returns the certificate source type associated to the implementation class.- Specified by:
getCertificateSourceTypein interfaceCertificateSource- Returns:
- the certificate origin
-
isTrusted
Description copied from interface:CertificateSourceThis method checks if a given certificate is trusted- Specified by:
isTrustedin interfaceCertificateSource- Parameters:
certificateToken- the certificate to be tested- Returns:
- true if the certificate is trusted
-
isAllSelfSigned
public boolean isAllSelfSigned()Description copied from interface:CertificateSourceThis method checks if all certificates are self-signed- Specified by:
isAllSelfSignedin interfaceCertificateSource- Returns:
- true if all certificates are self-signed
-