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
FieldsModifier and TypeFieldDescriptionprotected final CertificateTokenRefMatcherThis object is used to matchCertificateTokens andCertificateRefs -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCertificate(CertificateToken certificateToAdd) This method adds an external certificate to the source.findTokensFromCertRef(CertificateRef certificateRef) Returns Set ofCertificateTokens for the providedCertificateRefgetByCertificateDigest(Digest digest) This method returns the Set of certificates with theDigestgetByPublicKey(PublicKey publicKey) This method returns a list ofCertificateTokenwith the givenPublicKeygetBySignerIdentifier(SignerIdentifier signerIdentifier) This method returns the Set of certificates with theCertificateIdentifiergetBySki(byte[] ski) This method returns a list ofCertificateTokenwith 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 keysintThis method returns the number of stored certificates in this sourceintThis method returns the number of stored entities (unique public key) in this sourcebooleanThis method checks if all certificates are self-signedbooleanisCertificateSourceEqual(CertificateSource certificateSource) This method checks if the current and the givenCertificateSources contain the same certificate tokensbooleanisCertificateSourceEquivalent(CertificateSource certificateSource) This method checks if the current and the givenCertificateSources contain the same public keysbooleanisKnown(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 voidremoveCertificate(CertificateToken certificateToRemove) This method removes the corresponding certificate token from the certificate sourceprotected voidreset()This method removes all certificates from the source
-
Field Details
-
certificateMatcher
This object is used to matchCertificateTokens andCertificateRefs
-
-
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
-
removeCertificate
This method removes the corresponding certificate token from the certificate source- Parameters:
certificateToRemove-CertificateTokento remove
-
reset
protected void reset()This method removes all certificates from the source -
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
Description copied from interface:CertificateSourceReturns a list of certificates grouped by their public keys- Specified by:
getEntitiesin interfaceCertificateSource- Returns:
- a list of
CertificateSourceEntitys
-
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.
-
getBySignerIdentifier
Description copied from interface:CertificateSourceThis method returns the Set of certificates with theCertificateIdentifier- Specified by:
getBySignerIdentifierin 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:CertificateSourceThis method returns the Set of certificates with theDigest- Specified by:
getByCertificateDigestin interfaceCertificateSource- Parameters:
digest- the certificate digest to be found- Returns:
- the found certificates or an empty Set
-
findTokensFromCertRef
Description copied from interface:CertificateSourceReturns Set ofCertificateTokens for the providedCertificateRef- Specified by:
findTokensFromCertRefin interfaceCertificateSource- Parameters:
certificateRef- aCertificateRef- Returns:
- Set of
CertificateTokens
-
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
-
isCertificateSourceEqual
Description copied from interface:CertificateSourceThis method checks if the current and the givenCertificateSources contain the same certificate tokens- Specified by:
isCertificateSourceEqualin interfaceCertificateSource- Parameters:
certificateSource-CertificateSourceto compare- Returns:
- TRUE if both certificate sources contains the same certificate tokens, FALSE otherwise
-
isCertificateSourceEquivalent
Description copied from interface:CertificateSourceThis method checks if the current and the givenCertificateSources contain the same public keys- Specified by:
isCertificateSourceEquivalentin interfaceCertificateSource- Parameters:
certificateSource-CertificateSourceto compare- Returns:
- TRUE if both certificate sources contains the same public keys, FALSE otherwise
-