Class XAdESSignature
java.lang.Object
eu.europa.esig.dss.validation.DefaultAdvancedSignature
eu.europa.esig.dss.xades.validation.XAdESSignature
- All Implemented Interfaces:
AdvancedSignature
,Serializable
public class XAdESSignature extends DefaultAdvancedSignature
Parse an XAdES signature structure. Note that for each signature to be validated a new instance of this object must
be created.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class eu.europa.esig.dss.validation.DefaultAdvancedSignature
detachedContents, manifestFiles, offlineCertificateSource, providedSigningCertificateToken, referenceValidations, signatureCRLSource, signatureCryptographicVerification, signatureIdentifier, signatureOCSPSource, signaturePolicy, signatureTimestampSource, structureValidation
-
Constructor Summary
Constructors Constructor Description XAdESSignature(Element signatureElement)
This constructor is used when creating the signature.XAdESSignature(Element signatureElement, List<XAdESPaths> xadesPathsHolders)
The default constructor for XAdESSignature. -
Method Summary
Modifier and Type Method Description protected SignatureIdentifier
buildSignatureIdentifier()
Build and definessignatureIdentifier
valuevoid
checkSignatureIntegrity()
Verifies the signature integrity; checks if the signed content has not been tampered with.void
checkSignaturePolicy(SignaturePolicyProvider signaturePolicyProvider)
SignatureCertificateSource
getCertificateSource()
Gets a certificate source which contains ALL certificates embedded in the signature.Element
getCertificateValues()
List<SignerRole>
getCertifiedSignerRoles()
Returns the certified roles of the signer.List<SignerRole>
getClaimedSignerRoles()
Returns the claimed roles of the signer.List<CommitmentTypeIndication>
getCommitmentTypeIndications()
This method obtains the information concerning commitment type indication linked to the signatureElement
getCompleteCertificateRefs()
Element
getCompleteRevocationRefs()
String
getContentHints()
String
getContentIdentifier()
String
getContentType()
Returns the value of the signed attribute content-typeList<AdvancedSignature>
getCounterSignatures()
This method retrieves the potential countersignatures embedded in the XAdES signature document.OfflineCRLSource
getCRLSource()
Gets a CRL source which contains ALL CRLs embedded in the signature.String
getDAIdentifier()
This method returns an identifier provided by the Driving Application (DA) Note: used only for XAdESSignatureLevel
getDataFoundUpToLevel()
This method returns the signature levelDigestAlgorithm
getDigestAlgorithm()
Retrieves the digest algorithm used for generating the signature.EncryptionAlgorithm
getEncryptionAlgorithm()
Retrieves the encryption algorithm used for generating the signature.Element
getLastTimestampValidationData()
This method returns the last timestamp validation data for an archive timestamp.Node
getManifestById(String uri)
List<ReferenceValidation>
getManifestReferences(Node manifestNode)
Returns a list of all references contained in the given manifestMaskGenerationFunction
getMaskGenerationFunction()
Retrieves the mask generation function used for generating the signature.String
getMimeType()
Returns the value of the signed attribute mime-typeNode
getObjectById(String uri)
NodeList
getObjects()
This method returns the list of ds:Object elements for the current signature element.OfflineOCSPSource
getOCSPSource()
Gets an OCSP source which contains ALL OCSP responses embedded in the signature.List<org.apache.xml.security.signature.Reference>
getReferences()
List<ReferenceValidation>
getReferenceValidations()
Returns individual validation foreach reference (XAdES) or for the message-imprint (CAdES)Element
getRevocationValues()
NodeList
getSigAndRefsTimeStamp()
SignatureAlgorithm
getSignatureAlgorithm()
Retrieves the signature algorithm (or cipher) used for generating the signature.SignatureDigestReference
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.Element
getSignatureElement()
Returns the w3c.dom encapsulated signature element.SignatureForm
getSignatureForm()
Specifies the format of the signatureSignatureLevel[]
getSignatureLevels()
List<Element>
getSignatureObjects()
SignatureProductionPlace
getSignatureProductionPlace()
Returns information about the place where the signature was generatedbyte[]
getSignatureValue()
Returns the digital signature valueString
getSignatureValueBase64()
Returns a base64 SignatureValueString
getSignatureValueId()
List<SignerRole>
getSignedAssertions()
Returns the list of embeded signed assertions.List<String>
getSignedDataObjectProperties()
List<String>
getSignedProperties()
List<String>
getSignedSignatureProperties()
Date
getSigningTime()
Returns the signing time included within the signature.XAdESTimestampSource
getTimestampSource()
Gets a Signature Timestamp source which contains ALL timestamps embedded in the signature.List<String>
getUnsignedProperties()
List<String>
getUnsignedSignatureProperties()
Retrieves the name of each node found under the unsignedSignatureProperties elementDSSNamespace
getXadesNamespace()
XAdESPaths
getXAdESPaths()
DSSNamespace
getXmldSigNamespace()
boolean
hasBProfile()
Checks the presence of ... segment in the signature, what is the proof -B profile existenceboolean
hasCProfile()
Checks the presence of CompleteCertificateRefs and CompleteRevocationRefs segments in the signature, what is the proof -C profile existenceboolean
hasXProfile()
Checks the presence of SigAndRefsTimeStamp segment in the signature, what is the proof -X profile existencevoid
recursiveNamespaceBrowser(Element element)
This method sets the namespace which will determinate theXAdESPaths
to use.void
registerXAdESPaths(XAdESPaths xadesPaths)
This method allows to register a newXAdESPaths
.void
resetCertificateSource()
This method resets the source of certificates.void
resetRevocationSources()
This method resets the sources of the revocation data.void
resetTimestampSource()
This method resets the timestamp source.void
setDisableXSWProtection(boolean disableXSWProtection)
NOT RECOMMENDED : This parameter allows to disable protection against XML Signature wrapping attacks (XSW).void
validateStructure()
This method allows the structure validation of the signature.Methods inherited from class eu.europa.esig.dss.validation.DefaultAdvancedSignature
addExternalTimestamp, areAllSelfSignedCertificates, equals, findSignatureScope, getAllTimestamps, getArchiveTimestamps, getCandidatesForSigningCertificate, getCertificates, getCertificateSourcesExceptLastArchiveTimestamp, getCompleteCertificateSource, getCompleteCRLSource, getCompleteOCSPSource, getContainerContents, getContentTimestamps, getDetachedContents, getDocumentTimestamps, getDSSId, getId, getManifestedDocuments, getMasterSignature, getMessageDigestValue, getPdfRevision, getPolicyId, getProvidedSigningCertificateToken, getSignatureCryptographicVerification, getSignatureFilename, getSignatureScopes, getSignatureTimestamps, getSignatureValidationContext, getSignerInformationStoreInfos, getSignerRoles, getSigningCertificateToken, getStructureValidationResult, getTimestampsX1, getTimestampsX2, hashCode, hasLTAProfile, hasLTProfile, hasTProfile, isCounterSignature, isDocHashOnlyValidation, isHashOnlyValidation, prepareOfflineCertificateVerifier, prepareTimestamps, setContainerContents, setDetachedContents, setManifestFiles, setMasterSignature, setProvidedSigningCertificateToken, setSignatureFilename, toString
-
Constructor Details
-
XAdESSignature
This constructor is used when creating the signature. The defaultXPathQueryHolder
is set.- Parameters:
signatureElement
- the signature DOM element
-
XAdESSignature
The default constructor for XAdESSignature.- Parameters:
signatureElement
- the signature DOM elementxadesPathsHolders
- List ofXAdESPaths
to use when handling signature
-
-
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
This method sets the namespace which will determinate theXAdESPaths
to use. The content of the Transform element is ignored.- Parameters:
element
-
-
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 -
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
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:
-
resetCertificateSource
public void resetCertificateSource()This method resets the source of certificates. It must be called when any certificate is added to the KeyInfo or CertificateValues. -
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
-
resetRevocationSources
public void resetRevocationSources()This method resets the sources of the revocation data. It must be called when -LT level is created. -
getTimestampSource
Description copied from interface:AdvancedSignature
Gets a Signature Timestamp source which contains ALL timestamps embedded in the signature.- Returns:
SignatureTimestampSource
-
resetTimestampSource
public void resetTimestampSource()This method resets the timestamp source. It must be called when -LT level is created. -
getSigningTime
Description copied from interface:AdvancedSignature
Returns the signing time included within the signature.- Returns:
Date
representing the signing time or null
-
checkSignaturePolicy
-
getSignatureProductionPlace
Description copied from interface:AdvancedSignature
Returns information about the place where the signature was generated- Returns:
SignatureProductionPlace
-
getSignedAssertions
Description copied from interface:AdvancedSignature
Returns the list of embeded 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
-
getContentIdentifier
- Returns:
- content identifier as
String
-
getContentHints
- Returns:
- content hints as
String
-
getSignatureValueBase64
Returns a base64 SignatureValue- Returns:
- base64
String
-
getSignatureValue
public byte[] getSignatureValue()Description copied from interface:AdvancedSignature
Returns the digital signature value- Returns:
- digital signature value byte array
-
getSignatureValueId
-
getObjects
This method returns the list of ds:Object elements for the current signature element.- Returns:
-
getCompleteCertificateRefs
-
getCompleteRevocationRefs
-
getSigAndRefsTimeStamp
-
getCertificateValues
-
getRevocationValues
-
hasBProfile
public boolean hasBProfile()Checks the presence of ... segment in the signature, what is the proof -B profile existence- Returns:
- true if B Profile is detected
-
hasCProfile
public boolean hasCProfile()Checks the presence of CompleteCertificateRefs and CompleteRevocationRefs segments in the signature, what is the proof -C profile existence- Returns:
- true if C Profile is detected
-
hasXProfile
public boolean hasXProfile()Checks the presence of SigAndRefsTimeStamp segment in the signature, what is the proof -X profile existence- Returns:
- true if the -X extension is present
-
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) 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
-
getManifestReferences
Returns a list of all references contained in the given manifest- Parameters:
manifestNode
-Node
to get references from- Returns:
- list of
ReferenceValidation
objects
-
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
-
buildSignatureIdentifier
Description copied from class:DefaultAdvancedSignature
Build and definessignatureIdentifier
value- Specified by:
buildSignatureIdentifier
in classDefaultAdvancedSignature
-
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
Retrieves the name of each node found under the unsignedSignatureProperties element- Returns:
- an ArrayList containing the retrieved node names
-
getSignedSignatureProperties
-
getSignedProperties
-
getUnsignedProperties
-
getSignedDataObjectProperties
-
getDataFoundUpToLevel
Description copied from interface:AdvancedSignature
This method returns the signature level- Returns:
- a value of
SignatureLevel
-
getSignatureLevels
- Returns:
- the list of signature levels for this type of signature, in the simple to complete order. Example: B,T,LT,LTA
-
validateStructure
public void validateStructure()Description copied from interface:AdvancedSignature
This method allows the structure validation of the signature.- Specified by:
validateStructure
in interfaceAdvancedSignature
- Overrides:
validateStructure
in classDefaultAdvancedSignature
-
getLastTimestampValidationData
This method returns the last timestamp validation data for an archive timestamp.- Returns:
-
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
-
getSignatureObjects
- Returns:
-
registerXAdESPaths
This method allows to register a newXAdESPaths
.- Parameters:
xadesPaths
-XAdESPaths
to register
-