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
,KidCertificateSource
,TokenCertificateSource
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
Modifier and TypeFieldDescriptionprotected final CertificateTokenRefMatcher
This object is used to matchCertificateToken
s andCertificateRef
s -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddCertificate
(CertificateToken certificateToAdd) This method adds an external certificate to the source.findTokensFromCertRef
(CertificateRef certificateRef) Returns Set ofCertificateToken
s for the providedCertificateRef
getByCertificateDigest
(Digest digest) This method returns the Set of certificates with theDigest
getByPublicKey
(PublicKey publicKey) This method returns a list ofCertificateToken
with the givenPublicKey
getBySignerIdentifier
(SignerIdentifier signerIdentifier) This method returns the Set of certificates with theCertificateIdentifier
getBySki
(byte[] ski) This method returns a list ofCertificateToken
with the given SKI (SubjectKeyIdentifier (SHA-1 of the PublicKey))getBySubject
(X500PrincipalHelper subject) This method returns the Set of certificates with the same subjectDN.Retrieves the unmodifiable list of all certificate tokens from this source.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 keysint
This method returns the number of stored certificates in this sourceint
This method returns the number of stored entities (unique public key) in this sourceboolean
This method checks if all certificates are self-signedboolean
isCertificateSourceEqual
(CertificateSource certificateSource) This method checks if the current and the givenCertificateSource
s contain the same certificate tokensboolean
isCertificateSourceEquivalent
(CertificateSource certificateSource) This method checks if the current and the givenCertificateSource
s contain the same public keysboolean
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
removeCertificate
(CertificateToken certificateToRemove) This method removes the corresponding certificate token from the certificate sourceprotected void
reset()
This method removes all certificates from the source
-
Field Details
-
certificateMatcher
This object is used to matchCertificateToken
s andCertificateRef
s
-
-
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
-
removeCertificate
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
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
Description copied from interface:CertificateSource
Returns a list of certificates grouped by their public keys- Specified by:
getEntities
in interfaceCertificateSource
- Returns:
- a list of
CertificateSourceEntity
s
-
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.
-
getBySignerIdentifier
Description copied from interface:CertificateSource
This method returns the Set of certificates with theCertificateIdentifier
- Specified by:
getBySignerIdentifier
in interfaceCertificateSource
- Parameters:
signerIdentifier
- the certificate identifier to match- Returns:
- If no match is found then an empty set is returned.
-
getByCertificateDigest
Description copied from interface:CertificateSource
This method returns the Set of certificates with theDigest
- Specified by:
getByCertificateDigest
in interfaceCertificateSource
- Parameters:
digest
- the certificate digest to be found- Returns:
- the found certificates or an empty Set
-
findTokensFromCertRef
Description copied from interface:CertificateSource
Returns Set ofCertificateToken
s for the providedCertificateRef
- Specified by:
findTokensFromCertRef
in interfaceCertificateSource
- Parameters:
certificateRef
- aCertificateRef
- Returns:
- Set of
CertificateToken
s
-
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
-
isCertificateSourceEqual
Description copied from interface:CertificateSource
This method checks if the current and the givenCertificateSource
s contain the same certificate tokens- Specified by:
isCertificateSourceEqual
in interfaceCertificateSource
- Parameters:
certificateSource
-CertificateSource
to compare- Returns:
- TRUE if both certificate sources contains the same certificate tokens, FALSE otherwise
-
isCertificateSourceEquivalent
Description copied from interface:CertificateSource
This method checks if the current and the givenCertificateSource
s contain the same public keys- Specified by:
isCertificateSourceEquivalent
in interfaceCertificateSource
- Parameters:
certificateSource
-CertificateSource
to compare- Returns:
- TRUE if both certificate sources contains the same public keys, FALSE otherwise
-