Package eu.europa.esig.dss.validation
Class DiagnosticDataBuilder
java.lang.Object
eu.europa.esig.dss.validation.DiagnosticDataBuilder
- Direct Known Subclasses:
CertificateDiagnosticDataBuilder
,SignedDocumentDiagnosticDataBuilder
Contains a common code for DiagnosticData building
-
Field Summary
Modifier and TypeFieldDescriptionprotected ListCertificateSource
The list of all certificate sourcesprotected Map<String,
CertificateToken> A map between certificate id Strings and the related CertificateTokensprotected DigestAlgorithm
The digest algorithm to use for digest computationprotected TokenIdentifierProvider
Generates ids for the tokensA map between references ids and their related token ids (used to map references for timestamped refs)protected Map<String,
CertificateToken> A map between certificate id Strings and the related CertificateTokens for signing certificatesThe cached map of trusted lists with corresponding TLInfoprotected TokenExtractionStrategy
The token extraction strategyprotected Set<CertificateToken>
The certificates used during the validation processprotected Set<RevocationToken>
The revocation used during the validation processprotected Date
The validation timeprotected Map<String,
XmlCertificate> The cached map of certificatesprotected Map<String,
XmlOrphanCertificateToken> The cached map of orphan certificatesprotected Map<String,
XmlOrphanRevocationToken> The cached map of orphan revocation dataprotected Map<String,
XmlRevocation> The cached map of revocation dataprotected Map<String,
XmlTrustedList> The cached map of trusted lists -
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor instantiating object with null values -
Method Summary
Modifier and TypeMethodDescriptionallCertificateSources
(ListCertificateSource allCertificateSources) This method allows to setListCertificateSource
containing all certificate sources used in the validator (including trusted certificate sources)build()
BuildsXmlDiagnosticData
protected XmlCertificate
buildDetachedXmlCertificate
(CertificateToken certToken) This method builds anXmlCertificate
from the givenCertificateToken
protected XmlRevocation
buildDetachedXmlRevocation
(RevocationToken<?> revocationToken) This method builds anXmlRevocation
from the givenRevocationToken
protected XmlOrphanCertificateToken
buildXmlOrphanCertificateToken
(CertificateToken certificateToken) This method builds anXmlOrphanCertificateToken
from the givenCertificateToken
protected XmlOrphanTokens
Builds a list ofXmlOrphanTokens
defaultDigestAlgorithm
(DigestAlgorithm digestAlgorithm) This method allows to set the defaultDigestAlgorithm
which will be used for tokens' DigestAlgoAndValue calculationprotected CertificateToken
getUsedCertificateByCertificateRef
(CertificateRef certificateRef) Returns used certificate by thecertificateRef
protected XmlBasicSignature
getXmlBasicSignature
(Token token) GetsXmlBasicSignature
for aToken
protected XmlCertificateRef
getXmlCertificateRef
(CertificateRef ref, CertificateRefOrigin origin) Builds aXmlCertificateRef
fromCertificateRef
protected XmlRevocationRef
getXmlCRLRevocationRef
(CRLRef crlRef, Set<RevocationRefOrigin> origins) Builds aXmlRevocationRef
fromCRLRef
protected XmlDigestAlgoAndValue
getXmlDigestAlgoAndValue
(DigestAlgorithm digestAlgo, byte[] digestValue) Builds aXmlDigestAlgoAndValue
forDigestAlgorithm
anddigestValue
protected XmlDigestAlgoAndValue
getXmlDigestAlgoAndValue
(Digest digest) Builds aXmlDigestAlgoAndValue
forDigest
protected List<XmlChainItem>
getXmlForCertificateChain
(Token token) Returns a certificate chain for thetoken
protected List<XmlChainItem>
getXmlForCertificateChain
(Token token, CertificateSource certificateSource) Returns a certificate chain for thetoken
from thecertificateSource
protected List<XmlChainItem>
getXmlForCertificateChain
(CertificateValidity certificateValidity, CertificateSource certificateSource) Builds a certificate chain for aCertificateValidity
protected XmlFoundCertificates
getXmlFoundCertificates
(Identifier tokenIdentifier, TokenCertificateSource certificateSource) Returns found certificates from the sourceprotected XmlRevocationRef
getXmlOCSPRevocationRef
(OCSPRef ocspRef, Set<RevocationRefOrigin> origins) Builds aXmlRevocationRef
fromOCSPRef
protected XmlOrphanCertificate
getXmlOrphanCertificate
(CertificateOrigin origin, CertificateToken certificateToken, TokenCertificateSource certificateSource, CertificateToken signingCertificate) This method builds anXmlOrphanCertificateToken
protected List<XmlRelatedCertificate>
getXmlRelatedCertificateForOrphanReferences
(TokenCertificateSource certificateSource) Returns a list ofXmlRelatedCertificate
s for orphan references withincertificateSource
protected <R extends Revocation>
List<XmlRevocationRef>getXmlRevocationRefs
(String tokenId, Map<RevocationRef<R>, Set<RevocationRefOrigin>> refsAndOrigins) Returns a list ofXmlRevocationRef
for a token withtokenId
protected XmlSignerInfo
getXmlSignerInfo
(SignerIdentifier signerIdentifier) Creates aXmlSignerInfo
fromSignerIdentifier
protected XmlSigningCertificate
getXmlSigningCertificate
(Identifier tokenIdentifier, CertificateValidity certificateValidity) Gets a signing certificate token for a token withtokenIdentifier
protected void
linkSigningCertificateAndChains
(Set<CertificateToken> certificates) Links the certificates and their certificate chainsprotected void
populateCertificateOriginMap
(Map<String, XmlRelatedCertificate> relatedCertificatesMap, CertificateOrigin origin, List<CertificateToken> certificateTokens, TokenCertificateSource certificateSource) Fills the certificates origins map with the given propertiesprotected void
populateOrphanCertificateOriginMap
(Map<String, XmlOrphanCertificate> orphanCertificatesMap, CertificateOrigin origin, List<CertificateToken> certificateTokens, TokenCertificateSource certificateSource, CertificateToken signingCertificate) Fills the orphan certificate map with the given valuesprotected XmlRelatedCertificate
populateXmlRelatedCertificatesList
(CertificateOrigin origin, CertificateToken cert, TokenCertificateSource certificateSource) Builds anXmlRelatedCertificate
protected void
populateXmlRelatedCertificatesList
(List<XmlRelatedCertificate> relatesCertificates, TokenCertificateSource certificateSource, CertificateToken cert, CertificateRef certificateRef) Builds anXmlRelatedCertificate
and populates therelatesCertificates
listtokenExtractionStrategy
(TokenExtractionStrategy tokenExtractionStrategy) This method allows to set theTokenExtractionStrategy
to follow for the token extractiontokenIdentifierProvider
(TokenIdentifierProvider identifierProvider) This method allows to set theTokenIdentifierProvider
for identifiers generationusedCertificates
(Set<CertificateToken> usedCertificates) This method allows to set the used certificatesusedRevocations
(Set<RevocationToken> usedRevocations) This method allows to set the used revocation datavalidationDate
(Date validationDate) This method allows to set the validation dateprotected void
verifyAgainstCertificateToken
(XmlCertificateRef xmlCertificateRef, CertificateRef ref, CertificateToken signingCertificate) Verifies the reference against a certificate token
-
Field Details
-
usedCertificates
The certificates used during the validation process -
usedRevocations
The revocation used during the validation process -
allCertificateSources
The list of all certificate sources -
validationDate
The validation time -
tokenExtractionStrategy
The token extraction strategy -
defaultDigestAlgorithm
The digest algorithm to use for digest computation -
identifierProvider
Generates ids for the tokens -
xmlCertsMap
The cached map of certificates -
xmlRevocationsMap
The cached map of revocation data -
xmlTrustedListsMap
The cached map of trusted lists -
xmlOrphanCertificateTokensMap
The cached map of orphan certificates -
xmlOrphanRevocationTokensMap
The cached map of orphan revocation data -
referenceMap
A map between references ids and their related token ids (used to map references for timestamped refs) -
certificateIdsMap
A map between certificate id Strings and the related CertificateTokens -
signingCertificateMap
A map between certificate id Strings and the related CertificateTokens for signing certificates -
tlInfoMap
The cached map of trusted lists with corresponding TLInfo
-
-
Constructor Details
-
DiagnosticDataBuilder
protected DiagnosticDataBuilder()Default constructor instantiating object with null values
-
-
Method Details
-
usedCertificates
This method allows to set the used certificates- Parameters:
usedCertificates
- the used certificates- Returns:
- the builder
-
usedRevocations
This method allows to set the used revocation data- Parameters:
usedRevocations
- the used revocation data- Returns:
- the builder
-
allCertificateSources
This method allows to setListCertificateSource
containing all certificate sources used in the validator (including trusted certificate sources)- Parameters:
allCertificateSources
- the list of trusted lists certificate sources- Returns:
- the builder
-
validationDate
This method allows to set the validation date- Parameters:
validationDate
- the validation date- Returns:
- the builder
-
tokenExtractionStrategy
public DiagnosticDataBuilder tokenExtractionStrategy(TokenExtractionStrategy tokenExtractionStrategy) This method allows to set theTokenExtractionStrategy
to follow for the token extraction- Parameters:
tokenExtractionStrategy
-TokenExtractionStrategy
to use- Returns:
- the builder
-
tokenIdentifierProvider
This method allows to set theTokenIdentifierProvider
for identifiers generation- Parameters:
identifierProvider
-TokenIdentifierProvider
to use- Returns:
- the builder
-
defaultDigestAlgorithm
This method allows to set the defaultDigestAlgorithm
which will be used for tokens' DigestAlgoAndValue calculation- Parameters:
digestAlgorithm
-DigestAlgorithm
to set as default- Returns:
- the builder
-
build
BuildsXmlDiagnosticData
- Returns:
XmlDiagnosticData
-
linkSigningCertificateAndChains
Links the certificates and their certificate chains- Parameters:
certificates
- a set ofCertificateToken
s
-
buildXmlOrphanTokens
Builds a list ofXmlOrphanTokens
- Returns:
XmlOrphanTokens
-
getXmlSignerInfo
Creates aXmlSignerInfo
fromSignerIdentifier
- Parameters:
signerIdentifier
-SignerIdentifier
- Returns:
XmlSignerInfo
-
buildDetachedXmlRevocation
This method builds anXmlRevocation
from the givenRevocationToken
- Parameters:
revocationToken
-RevocationToken
- Returns:
XmlRevocation
-
getXmlRevocationRefs
protected <R extends Revocation> List<XmlRevocationRef> getXmlRevocationRefs(String tokenId, Map<RevocationRef<R>, Set<RevocationRefOrigin>> refsAndOrigins) Returns a list ofXmlRevocationRef
for a token withtokenId
- Type Parameters:
R
-Revocation
- Parameters:
tokenId
-String
refsAndOrigins
- a map ofRevocationRef
s and theirRevocationRefOrigin
s- Returns:
- a list of
XmlRevocationRef
s
-
getXmlCRLRevocationRef
Builds aXmlRevocationRef
fromCRLRef
- Parameters:
crlRef
-CRLRef
origins
- a set ofRevocationRefOrigin
s- Returns:
XmlRevocationRef
-
getXmlOCSPRevocationRef
protected XmlRevocationRef getXmlOCSPRevocationRef(OCSPRef ocspRef, Set<RevocationRefOrigin> origins) Builds aXmlRevocationRef
fromOCSPRef
- Parameters:
ocspRef
-OCSPRef
origins
- a set ofRevocationRefOrigin
s- Returns:
XmlRevocationRef
-
getXmlForCertificateChain
Returns a certificate chain for thetoken
- Parameters:
token
-Token
- Returns:
- a list of
XmlChainItem
-
getXmlForCertificateChain
protected List<XmlChainItem> getXmlForCertificateChain(Token token, CertificateSource certificateSource) Returns a certificate chain for thetoken
from thecertificateSource
- Parameters:
token
-Token
certificateSource
-CertificateSource
- Returns:
- a list of
XmlChainItem
-
getXmlForCertificateChain
protected List<XmlChainItem> getXmlForCertificateChain(CertificateValidity certificateValidity, CertificateSource certificateSource) Builds a certificate chain for aCertificateValidity
- Parameters:
certificateValidity
-CertificateValidity
certificateSource
-CertificateSource
- Returns:
- a list of
XmlChainItem
-
getXmlSigningCertificate
protected XmlSigningCertificate getXmlSigningCertificate(Identifier tokenIdentifier, CertificateValidity certificateValidity) Gets a signing certificate token for a token withtokenIdentifier
- Parameters:
tokenIdentifier
-Identifier
certificateValidity
-CertificateValidity
- Returns:
XmlSigningCertificate
-
getXmlFoundCertificates
protected XmlFoundCertificates getXmlFoundCertificates(Identifier tokenIdentifier, TokenCertificateSource certificateSource) Returns found certificates from the source- Parameters:
tokenIdentifier
-Identifier
of the tokencertificateSource
-TokenCertificateSource
- Returns:
XmlFoundCertificates
-
populateCertificateOriginMap
protected void populateCertificateOriginMap(Map<String, XmlRelatedCertificate> relatedCertificatesMap, CertificateOrigin origin, List<CertificateToken> certificateTokens, TokenCertificateSource certificateSource) Fills the certificates origins map with the given properties- Parameters:
relatedCertificatesMap
- a map to fillorigin
-CertificateOrigin
certificateTokens
- a list ofCertificateToken
scertificateSource
-TokenCertificateSource
-
populateXmlRelatedCertificatesList
protected XmlRelatedCertificate populateXmlRelatedCertificatesList(CertificateOrigin origin, CertificateToken cert, TokenCertificateSource certificateSource) Builds anXmlRelatedCertificate
- Parameters:
origin
-CertificateOrigin
cert
-CertificateToken
certificateSource
-TokenCertificateSource
- Returns:
XmlRelatedCertificate
-
populateXmlRelatedCertificatesList
protected void populateXmlRelatedCertificatesList(List<XmlRelatedCertificate> relatesCertificates, TokenCertificateSource certificateSource, CertificateToken cert, CertificateRef certificateRef) Builds anXmlRelatedCertificate
and populates therelatesCertificates
list- Parameters:
relatesCertificates
- a list of created earlierXmlRelatedCertificate
certificateSource
-TokenCertificateSource
cert
-CertificateToken
certificateRef
-CertificateRef
-
getXmlCertificateRef
Builds aXmlCertificateRef
fromCertificateRef
- Parameters:
ref
-XmlCertificateRef
origin
-CertificateRefOrigin
- Returns:
XmlCertificateRef
-
populateOrphanCertificateOriginMap
protected void populateOrphanCertificateOriginMap(Map<String, XmlOrphanCertificate> orphanCertificatesMap, CertificateOrigin origin, List<CertificateToken> certificateTokens, TokenCertificateSource certificateSource, CertificateToken signingCertificate) Fills the orphan certificate map with the given values- Parameters:
orphanCertificatesMap
- a map to fillorigin
-CertificateOrigin
certificateTokens
- a list ofCertificateToken
scertificateSource
-TokenCertificateSource
signingCertificate
-CertificateToken
-
getXmlOrphanCertificate
protected XmlOrphanCertificate getXmlOrphanCertificate(CertificateOrigin origin, CertificateToken certificateToken, TokenCertificateSource certificateSource, CertificateToken signingCertificate) This method builds anXmlOrphanCertificateToken
- Parameters:
origin
-CertificateOrigin
certificateToken
-CertificateToken
certificateSource
-TokenCertificateSource
signingCertificate
-CertificateToken
- Returns:
XmlOrphanCertificateToken
-
buildXmlOrphanCertificateToken
protected XmlOrphanCertificateToken buildXmlOrphanCertificateToken(CertificateToken certificateToken) This method builds anXmlOrphanCertificateToken
from the givenCertificateToken
- Parameters:
certificateToken
-CertificateToken
- Returns:
XmlOrphanCertificateToken
-
getXmlRelatedCertificateForOrphanReferences
protected List<XmlRelatedCertificate> getXmlRelatedCertificateForOrphanReferences(TokenCertificateSource certificateSource) Returns a list ofXmlRelatedCertificate
s for orphan references withincertificateSource
- Parameters:
certificateSource
-TokenCertificateSource
- Returns:
- a list of
XmlRelatedCertificate
s
-
getUsedCertificateByCertificateRef
Returns used certificate by thecertificateRef
- Parameters:
certificateRef
-CertificateRef
- Returns:
CertificateToken
-
verifyAgainstCertificateToken
protected void verifyAgainstCertificateToken(XmlCertificateRef xmlCertificateRef, CertificateRef ref, CertificateToken signingCertificate) Verifies the reference against a certificate token- Parameters:
xmlCertificateRef
-XmlCertificateRef
ref
-CertificateRef
signingCertificate
-CertificateToken
-
getXmlBasicSignature
GetsXmlBasicSignature
for aToken
- Parameters:
token
-Token
- Returns:
XmlBasicSignature
-
buildDetachedXmlCertificate
This method builds anXmlCertificate
from the givenCertificateToken
- Parameters:
certToken
-CertificateToken
- Returns:
XmlCertificate
-
getXmlDigestAlgoAndValue
Builds aXmlDigestAlgoAndValue
forDigest
- Parameters:
digest
-Digest
- Returns:
XmlDigestAlgoAndValue
-
getXmlDigestAlgoAndValue
protected XmlDigestAlgoAndValue getXmlDigestAlgoAndValue(DigestAlgorithm digestAlgo, byte[] digestValue) Builds aXmlDigestAlgoAndValue
forDigestAlgorithm
anddigestValue
- Parameters:
digestAlgo
-DigestAlgorithm
digestValue
- digest value bytes- Returns:
XmlDigestAlgoAndValue
-