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 CertificateToken
addCertificate(CertificateToken certificateToAdd)
This method adds an external certificate to the source.Set<CertificateToken>
getByCertificateIdentifier(CertificateIdentifier certificateIdentifier)
This method returns the Set of certificates with theCertificateIdentifier
Set<CertificateToken>
getByPublicKey(PublicKey publicKey)
This method returns a list ofCertificateToken
with the givenPublicKey
Set<CertificateToken>
getBySki(byte[] ski)
This method returns a list ofCertificateToken
with 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.CertificateSourceType
getCertificateSourceType()
This method returns the certificate source type associated to the implementation class.List<eu.europa.esig.dss.spi.x509.CertificateSourceEntity>
getEntities()
int
getNumberOfCertificates()
This method returns the number of stored certificates in this sourceint
getNumberOfEntities()
This method returns the number of stored entities (unique public key) in this sourceboolean
isAllSelfSigned()
This method checks if all certificates are self-signedboolean
isKnown(CertificateToken token)
This method checks if a given certificate is known in the current sourceboolean
isTrusted(CertificateToken certificateToken)
This method checks if a given certificate is trustedprotected void
reset()
-
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:
addCertificate
in interfaceCertificateSource
- Parameters:
certificateToAdd
- the certificate to be added- Returns:
- the corresponding certificate token
-
reset
protected void reset() -
isKnown
Description copied from interface:CertificateSource
This method checks if a given certificate is known in the current source- Specified by:
isKnown
in 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:
getCertificates
in interfaceCertificateSource
- Returns:
- all certificates from this source
-
getEntities
- Specified by:
getEntities
in interfaceCertificateSource
-
getByPublicKey
This method returns a list ofCertificateToken
with the givenPublicKey
- Specified by:
getByPublicKey
in 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 ofCertificateToken
with the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))- Specified by:
getBySki
in 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:
getBySubject
in 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:CertificateSource
This method returns the Set of certificates with theCertificateIdentifier
- Specified by:
getByCertificateIdentifier
in 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:CertificateSource
This method returns the certificate source type associated to the implementation class.- Specified by:
getCertificateSourceType
in interfaceCertificateSource
- Returns:
- the certificate origin
-
isTrusted
Description copied from interface:CertificateSource
This method checks if a given certificate is trusted- Specified by:
isTrusted
in interfaceCertificateSource
- 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 interfaceCertificateSource
- Returns:
- true if all certificates are self-signed
-