Class XAdESSignature
java.lang.Object
eu.europa.esig.dss.spi.signature.DefaultAdvancedSignature
eu.europa.esig.dss.xades.validation.XAdESSignature
- All Implemented Interfaces:
IdentifierBasedObject
,AdvancedSignature
,Serializable
Parse an XAdES signature structure. Note that for each signature to be validated a new instance of this object must
be created.
- See Also:
-
Field Summary
Fields inherited from class eu.europa.esig.dss.spi.signature.DefaultAdvancedSignature
counterSignatures, detachedContents, manifestFile, offlineCertificateSource, referenceValidations, signatureCRLSource, signatureCryptographicVerification, signatureIdentifier, signatureOCSPSource, signaturePolicy, signatureTimestampSource, signingCertificateSource, structureValidationMessages
-
Constructor Summary
ConstructorDescriptionXAdESSignature
(Element signatureElement) This constructor is used when creating the signature.XAdESSignature
(Element signatureElement, List<XAdESPath> xadesPathHolders) The default constructor for XAdESSignature. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExternalTimestamp
(TimestampToken timestamp) This method allows to add an external timestamp.protected XAdESSignaturePolicy
This method extracts a signature policy from a signature and builds the objectvoid
Verifies the signature integrity; checks if the signed content has not been tampered with.protected XAdESBaselineRequirementsChecker
createBaselineRequirementsChecker
(CertificateVerifier certificateVerifier) Instantiates aBaselineRequirementsChecker
according to the signature formatprotected List
<SignatureScope> Finds signature scopesprotected XAdESBaselineRequirementsChecker
Returns a cached instance of theBaselineRequirementsChecker
Gets a certificate source which contains ALL certificates embedded in the signature.Gets xades:CertificateValues elementReturns the certified roles of the signer.Returns the claimed roles of the signer.This method obtains the information concerning commitment type indication linked to the signatureGets xades:CompleteCertificateRefs or xades141:CompleteCertificateRefsV2 elementGets xades:CompleteRevocationRefsReturns the value of the signed attribute content-typeThis method retrieves the potential countersignatures embedded in the XAdES signature document.Gets a CRL source which contains ALL CRLs embedded in the signature.This method returns an identifier provided by the Driving Application (DA) Note: used only for XAdESThis method returns the signature levelTS 119 102-1 (4.2.8 Data to be signed representation (DTBSR)) : The DTBS preparation component shall take the DTBSF and hash it according to the hash algorithm specified in the cryptographic suite.Retrieves the digest algorithm used for generating the signature.Retrieves the encryption algorithm used for generating the signature.This method returns the last timestamp validation data for an archive timestamp.Gets ds:Manifest by its IdDeprecated.Returns the value of the signed attribute mime-typegetObjectById
(String id) Gets ds:Object by its IdThis method returns the list of ds:Object elements for the current signature element.Gets an OCSP source which contains ALL OCSP responses embedded in the signature.List
<org.apache.xml.security.signature.Reference> Gets a list of found referencesReturns individual validation foreach reference (XAdES, JAdES) or for the message-imprint (CAdES)Gets xades:RefsOnlyTimestamp node listGets xades:RevocationValues elementGets xades:SigAndRefsTimeStamp node listRetrieves the signature algorithm (or cipher) used for generating the signature.getSignatureDigestReference
(DigestAlgorithm digestAlgorithm) TS 119 442 - V1.1.1 - Electronic Signatures and Infrastructures (ESI), ch. 5.1.4.2.1.3 XML component: In case of XAdES signatures, the input of the digest value computation shall be the result of applying the canonicalization algorithm identified within the CanonicalizationMethod child element's value to the corresponding ds:Signature element and its contents.Returns the w3c.dom encapsulated signature element.Specifies the format of the signatureprotected SignatureIdentifierBuilder
Returns a builder to define and build a signature IdGets a list of found signature ds:Object elementsReturns the Signature Policy OID from the signature.Returns the Signature Policy Store from the signatureReturns information about the place where the signature was generatedbyte[]
Returns the digital signature valueReturns a base64 SignatureValueReturns Id of the ds:SignatureValue elementReturns the list of embedded signed assertions.Retrieves the name of each node found under the SignedDataObjectProperties elementReturns the ds:SignedInfo elementRetrieves the name of each node found under the SignedProperties elementRetrieves the name of each node found under the SignedSignatureProperties elementReturns the signing time included within the signature.Gets a Signature Timestamp source which contains ALL timestamps embedded in the signature.Retrieves the name of each node found under the UnsignedProperties elementRetrieves the name of each node found under the UnsignedSignatureProperties elementReturns the XAdES namespaceGets the currentXAdESPaths
Returns a list of usedXAdESPaths
Returns the XMLDSIG namespacevoid
recursiveNamespaceBrowser
(Element element) This method sets the namespace which will determinate theXAdESPaths
to use.void
registerXAdESPaths
(XAdESPath xadesPaths) This method allows to register a newXAdESPaths
.void
setDisableXSWProtection
(boolean disableXSWProtection) NOT RECOMMENDED : This parameter allows to disable protection against XML Signature wrapping attacks (XSW).This method processes the structure validation of the signature.Methods inherited from class eu.europa.esig.dss.spi.signature.DefaultAdvancedSignature
addExternalEvidenceRecord, areAllSelfSignedCertificates, equals, getAllEvidenceRecords, getAllTimestamps, getArchiveTimestamps, getCandidatesForSigningCertificate, getCertificates, getCompleteCertificateSource, getCompleteCRLSource, getCompleteOCSPSource, getContainerContents, getContentTimestamps, getCounterSignaturesCertificateSource, getCounterSignaturesCRLSource, getCounterSignaturesOCSPSource, getDetachedContents, getDetachedEvidenceRecords, getDetachedTimestamps, getDocumentTimestamps, getDSSId, getEmbeddedEvidenceRecords, getId, getManifestFile, getMasterSignature, getSignatureCryptographicVerification, getSignatureFilename, getSignatureScopes, getSignatureTimestamps, getSignerRoles, getSigningCertificateToken, getStructureValidationResult, getTimestampsX1, getTimestampsX2, hasAProfile, hasBESProfile, hasBProfile, hasCProfile, hasEPESProfile, hasExtendedTProfile, hashCode, hasLTAProfile, hasLTProfile, hasTProfile, hasXLProfile, hasXProfile, initBaselineRequirementsChecker, isCounterSignature, isDocHashOnlyValidation, isHashOnlyValidation, resetCertificateSource, resetRevocationSources, resetTimestampSource, setContainerContents, setDetachedContents, setManifestFile, setMasterSignature, setSignatureFilename, setSigningCertificateSource, toString
-
Constructor Details
-
XAdESSignature
This constructor is used when creating the signature. The defaultXPathQueryHolder
is set.- Parameters:
signatureElement
- the signature DOM element
-
XAdESSignature
-
-
Method Details
-
setDisableXSWProtection
public void setDisableXSWProtection(boolean disableXSWProtection) NOT RECOMMENDED : This parameter allows to disable protection against XML Signature wrapping attacks (XSW). It disables the research by XPath expression for defined Type attributes.- Parameters:
disableXSWProtection
- true to disable the protection
-
recursiveNamespaceBrowser
-
getXAdESPathsHolders
-
getXAdESPaths
-
getXmldSigNamespace
-
getXadesNamespace
-
getSignatureElement
Returns the w3c.dom encapsulated signature element.- Returns:
- the signatureElement
-
getSignatureForm
Description copied from interface:AdvancedSignature
Specifies the format of the signature- Returns:
SignatureForm
-
getEncryptionAlgorithm
Description copied from interface:AdvancedSignature
Retrieves the encryption algorithm used for generating the signature.- Returns:
EncryptionAlgorithm
-
getDigestAlgorithm
Description copied from interface:AdvancedSignature
Retrieves the digest algorithm used for generating the signature.- Returns:
DigestAlgorithm
-
getMaskGenerationFunction
Deprecated.Description copied from interface:AdvancedSignature
Retrieves the mask generation function used for generating the signature.- Returns:
MaskGenerationFunction
-
getSignatureAlgorithm
Description copied from interface:AdvancedSignature
Retrieves the signature algorithm (or cipher) used for generating the signature.- Returns:
SignatureAlgorithm
-
getCertificateSource
Description copied from interface:AdvancedSignature
Gets a certificate source which contains ALL certificates embedded in the signature.- Returns:
SignatureCertificateSource
-
getCRLSource
Description copied from interface:AdvancedSignature
Gets a CRL source which contains ALL CRLs embedded in the signature.- Returns:
OfflineRevocationSource
-
getOCSPSource
Description copied from interface:AdvancedSignature
Gets an OCSP source which contains ALL OCSP responses embedded in the signature.- Returns:
OfflineRevocationSource
-
getTimestampSource
Description copied from interface:AdvancedSignature
Gets a Signature Timestamp source which contains ALL timestamps embedded in the signature.- Returns:
SignatureTimestampSource
-
getSigningTime
Description copied from interface:AdvancedSignature
Returns the signing time included within the signature.- Returns:
Date
representing the signing time or null
-
getSignaturePolicy
Description copied from interface:AdvancedSignature
Returns the Signature Policy OID from the signature.- Specified by:
getSignaturePolicy
in interfaceAdvancedSignature
- Overrides:
getSignaturePolicy
in classDefaultAdvancedSignature
- Returns:
SignaturePolicy
-
buildSignaturePolicy
Description copied from class:DefaultAdvancedSignature
This method extracts a signature policy from a signature and builds the object- Specified by:
buildSignaturePolicy
in classDefaultAdvancedSignature
- Returns:
SignaturePolicy
-
getSignatureProductionPlace
Description copied from interface:AdvancedSignature
Returns information about the place where the signature was generated- Returns:
SignatureProductionPlace
-
getSignaturePolicyStore
Description copied from interface:AdvancedSignature
Returns the Signature Policy Store from the signature- Returns:
SignaturePolicyStore
-
getSignedAssertions
Description copied from interface:AdvancedSignature
Returns the list of embedded signed assertions.- Returns:
- list of the assertions s
-
getClaimedSignerRoles
Description copied from interface:AdvancedSignature
Returns the claimed roles of the signer.- Returns:
- list of the
SignerRole
s
-
getCertifiedSignerRoles
Description copied from interface:AdvancedSignature
Returns the certified roles of the signer.- Returns:
- list of the
SignerRole
s
-
getContentType
Description copied from interface:AdvancedSignature
Returns the value of the signed attribute content-type- Returns:
- content type as
String
-
getMimeType
Description copied from interface:AdvancedSignature
Returns the value of the signed attribute mime-type- Returns:
- mime type as
String
-
getSignatureValueBase64
-
getSignatureValue
public byte[] getSignatureValue()Description copied from interface:AdvancedSignature
Returns the digital signature value- Returns:
- digital signature value byte array
-
getSignatureValueId
-
getObjects
-
getCompleteCertificateRefs
-
getCompleteRevocationRefs
-
getSigAndRefsTimeStamp
-
getRefsOnlyTimestampTimeStamp
-
getCertificateValues
-
getRevocationValues
-
addExternalTimestamp
Description copied from interface:AdvancedSignature
This method allows to add an external timestamp. The given timestamp must be processed before. NOTE: The method is supported only for CAdES signatures- Parameters:
timestamp
- the timestamp token
-
getBaselineRequirementsChecker
Description copied from class:DefaultAdvancedSignature
Returns a cached instance of theBaselineRequirementsChecker
- Overrides:
getBaselineRequirementsChecker
in classDefaultAdvancedSignature
- Returns:
BaselineRequirementsChecker
-
createBaselineRequirementsChecker
protected XAdESBaselineRequirementsChecker createBaselineRequirementsChecker(CertificateVerifier certificateVerifier) Description copied from class:DefaultAdvancedSignature
Instantiates aBaselineRequirementsChecker
according to the signature format- Specified by:
createBaselineRequirementsChecker
in classDefaultAdvancedSignature
- Parameters:
certificateVerifier
-CertificateVerifier
to be used- Returns:
BaselineRequirementsChecker
-
checkSignatureIntegrity
public void checkSignatureIntegrity()Description copied from interface:AdvancedSignature
Verifies the signature integrity; checks if the signed content has not been tampered with. In the case of a non-AdES signature no including the signing certificate then the latter must be provided by callingsetProvidedSigningCertificateToken
In the case of a detached signature the signed content must be provided by callingsetProvidedSigningCertificateToken
-
getReferenceValidations
Description copied from interface:AdvancedSignature
Returns individual validation foreach reference (XAdES, JAdES) or for the message-imprint (CAdES)- Returns:
- a list with one or more
ReferenceValidation
-
getSignatureDigestReference
TS 119 442 - V1.1.1 - Electronic Signatures and Infrastructures (ESI), ch. 5.1.4.2.1.3 XML component: In case of XAdES signatures, the input of the digest value computation shall be the result of applying the canonicalization algorithm identified within the CanonicalizationMethod child element's value to the corresponding ds:Signature element and its contents. The canonicalization shall be computed keeping this ds:Signature element as a descendant of the XML root element, without detaching it.- Parameters:
digestAlgorithm
-DigestAlgorithm
to use- Returns:
SignatureDigestReference
-
getDataToBeSignedRepresentation
Description copied from interface:AdvancedSignature
TS 119 102-1 (4.2.8 Data to be signed representation (DTBSR)) : The DTBS preparation component shall take the DTBSF and hash it according to the hash algorithm specified in the cryptographic suite.- Returns:
Digest
DTBSR, which is then used to create the signature.
-
getSignedInfo
-
getObjectById
-
getManifestById
-
getCounterSignatures
This method retrieves the potential countersignatures embedded in the XAdES signature document. From ETSI TS 101 903 v1.4.2: 7.2.4.1 Countersignature identifier in Type attribute of ds:Reference A XAdES signature containing a ds:Reference element whose Type attribute has value "http://uri.etsi.org/01903#CountersignedSignature" will indicate that is is, in fact, a countersignature of the signature referenced by this element. 7.2.4.2 Enveloped countersignatures: the CounterSignature element The CounterSignature is an unsigned property that qualifies the signature. A XAdES signature MAY have more than one CounterSignature properties. As indicated by its name, it contains one countersignature of the qualified signature.- Returns:
- a list containing the countersignatures embedded in the XAdES signature document
-
getSignatureIdentifierBuilder
Description copied from class:DefaultAdvancedSignature
Returns a builder to define and build a signature Id- Specified by:
getSignatureIdentifierBuilder
in classDefaultAdvancedSignature
- Returns:
SignatureIdentifierBuilder
-
getDAIdentifier
Description copied from interface:AdvancedSignature
This method returns an identifier provided by the Driving Application (DA) Note: used only for XAdES- Returns:
- The signature identifier
-
getUnsignedSignatureProperties
-
getSignedSignatureProperties
-
getSignedProperties
-
getUnsignedProperties
-
getSignedDataObjectProperties
-
getDataFoundUpToLevel
Description copied from interface:AdvancedSignature
This method returns the signature level- Returns:
- a value of
SignatureLevel
-
validateStructure
Description copied from class:DefaultAdvancedSignature
This method processes the structure validation of the signature.- Overrides:
validateStructure
in classDefaultAdvancedSignature
- Returns:
- list of
String
errors
-
findSignatureScopes
Description copied from class:DefaultAdvancedSignature
Finds signature scopes- Specified by:
findSignatureScopes
in classDefaultAdvancedSignature
- Returns:
- a list of
SignatureScope
s
-
getLastTimestampValidationData
-
getCommitmentTypeIndications
Description copied from interface:AdvancedSignature
This method obtains the information concerning commitment type indication linked to the signature- Returns:
- a list of
CommitmentTypeIndication
s
-
getReferences
Gets a list of found references- Returns:
- a list of
Reference
s
-
getSignatureObjects
-
registerXAdESPaths
This method allows to register a newXAdESPaths
.- Parameters:
xadesPaths
-XAdESPaths
to register
-