C# Class Microsoft.Xades.XadesSignedXml

Facade class for the XAdES signature library. The class inherits from the System.Security.Cryptography.Xml.SignedXml class and is backwards compatible with it, so this class can host xmldsig signatures and XAdES signatures. The property SignatureStandard will indicate the type of the signature: XMLDSIG or XAdES.
Inheritance: System.Security.Cryptography.Xml.SignedXml
Exibir arquivo Open project: Caliper/Xades Class Usage Examples

Public Methods

Method Description
AddXadesObject ( XadesObject xadesObject ) : void

Add a XAdES object to the signature

CheckAllHashDataInfosInIndividualDataObjectsTimeStamp ( ) : bool

Check if the HashDataInfo of each IndividualDataObjectsTimeStamp points to existing Reference

CheckAllReferencesExistInAllDataObjectsTimeStamp ( ) : bool

Check if there is a HashDataInfo for each reference if there is a AllDataObjectsTimeStamp

CheckArchiveTimeStampHashDataInfos ( ) : bool

Check if all required HashDataInfos are present on ArchiveTimeStamp

CheckCertificateValuesMatchCertificateRefs ( ) : bool

Check if CertificateValues match CertificateRefs

CheckCounterSignatures ( XadesCheckSignatureMasks counterSignatureMask ) : bool

Perform XAdES checks on contained counter signatures. If couter signature is XMLDSIG, only XMLDSIG check (CheckSignature()) is done.

CheckCounterSignaturesReference ( ) : bool

Counter signatures should all contain a reference to the parent signature SignatureValue element

CheckHashDataInfoOfSignatureTimeStampPointsToSignatureValue ( ) : bool

Check if HashDataInfo of SignatureTimeStamp points to SignatureValue

CheckIfClaimedRolesOrCertifiedRolesPresentInSignerRole ( ) : bool

Check if at least ClaimedRoles or CertifiedRoles present in SignerRole

CheckObjectReferencesInCommitmentTypeIndication ( ) : bool

Check if each ObjectReference in CommitmentTypeIndication points to Reference element

CheckQualifyingProperties ( ) : bool

Check that QualifyingProperties occur in one Object, check that there is only one QualifyingProperties and that signed properties occur in one QualifyingProperties element

CheckQualifyingPropertiesTarget ( ) : bool

Check if the QualifyingProperties Target attribute points to the signature element

CheckRefsOnlyTimeStampHashDataInfos ( ) : bool

Check if all required HashDataInfos are present on RefsOnlyTimeStamp

CheckRevocationValuesMatchRevocationRefs ( ) : bool

Check if RevocationValues match RevocationRefs

CheckSameCertificate ( ) : bool

Check to see if first XMLDSIG certificate has same hashvalue as first XAdES SignatureCertificate

CheckSigAndRefsTimeStampHashDataInfos ( ) : bool

Check if all required HashDataInfos are present on SigAndRefsTimeStamp

CheckXadesCIsXadesT ( ) : bool

Check if a XAdES-C signature is also a XAdES-T signature

CheckXadesXLIsXadesX ( ) : bool

Check if a XAdES-XL signature is also a XAdES-X signature

CheckXmldsigSignature ( ) : bool

Check the signature of the underlying XMLDSIG signature

ComputeSignature ( ) : void

Copy of System.Security.Cryptography.Xml.SignedXml.ComputeSignature() which will end up calling our own GetC14NDigest with a namespace prefix for all XmlDsig nodes

GetIdElement ( XmlDocument xmlDocument, string idValue ) : XmlElement

Overridden virtual method to be able to find the nested SignedProperties element inside of the XAdES object

GetXml ( ) : XmlElement

Returns the XML representation of the this object

LoadXml ( System xmlElement ) : void

Load state from an XML element

ValidateAgainstSchema ( ) : bool

Validate the XML representation of the signature against the XAdES and XMLDSIG schemas

XadesCheckSignature ( XadesCheckSignatureMasks xadesCheckSignatureMasks ) : bool

Additional tests for XAdES signatures. These tests focus on XMLDSIG verification and correct form of the XAdES XML structure (schema validation and completeness as defined by the XAdES standard).

Because of the fact that the XAdES library is intentionally independent of standards like TSP (RFC3161) or OCSP (RFC2560), these tests do NOT include any verification of timestamps nor OCSP responses. These checks are important and have to be done in the application built on top of the XAdES library.

XadesSignedXml ( ) : System

Default constructor for the XadesSignedXml class

XadesSignedXml ( System signatureDocument ) : System

Constructor for the XadesSignedXml class

XadesSignedXml ( XmlElement signatureElement ) : System

Constructor for the XadesSignedXml class

Private Methods

Method Description
BuildDigestedReferences ( ) : void

Copy of System.Security.Cryptography.Xml.SignedXml.BuildDigestedReferences() which will add a "ds" namespace prefix to all XmlDsig nodes

CheckHashDataInfoPointsToSignatureValue ( TimeStamp timeStamp ) : bool
CheckHashDataInfosExist ( TimeStamp timeStamp ) : bool
CheckHashDataInfosForTimeStamp ( TimeStamp timeStamp ) : bool
CheckHashDataInfosOfArchiveTimeStamp ( TimeStamp timeStamp ) : bool
CheckHashDataInfosOfRefsOnlyTimeStamp ( TimeStamp timeStamp ) : bool
CheckHashDataInfosOfSigAndRefsTimeStamp ( TimeStamp timeStamp ) : bool
CheckObjectReference ( ObjectReference objectReference ) : bool
GetC14NDigest ( HashAlgorithm hash ) : byte[]

We won't call System.Security.Cryptography.Xml.SignedXml.GetC14NDigest(), as we want to use our own.

GetC14NDigest ( HashAlgorithm hash, string prefix ) : byte[]

Copy of System.Security.Cryptography.Xml.SignedXml.GetC14NDigest() which will add a namespace prefix to all XmlDsig nodes

GetXadesDataObject ( ) : System.Security.Cryptography.Xml.DataObject
GetXadesObjectElement ( XmlElement signatureElement ) : XmlElement
SchemaValidationHandler ( object sender, ValidationEventArgs validationEventArgs ) : void
SetPrefix ( String prefix, XmlNode node ) : void
SetSignatureStandard ( XmlElement signatureElement ) : void
XmlValidationHandler ( object sender, ValidationEventArgs validationEventArgs ) : void

Method Details

AddXadesObject() public method

Add a XAdES object to the signature
public AddXadesObject ( XadesObject xadesObject ) : void
xadesObject XadesObject XAdES object to add to signature
return void

CheckAllHashDataInfosInIndividualDataObjectsTimeStamp() public method

Check if the HashDataInfo of each IndividualDataObjectsTimeStamp points to existing Reference

CheckAllReferencesExistInAllDataObjectsTimeStamp() public method

Check if there is a HashDataInfo for each reference if there is a AllDataObjectsTimeStamp
public CheckAllReferencesExistInAllDataObjectsTimeStamp ( ) : bool
return bool

CheckArchiveTimeStampHashDataInfos() public method

Check if all required HashDataInfos are present on ArchiveTimeStamp
public CheckArchiveTimeStampHashDataInfos ( ) : bool
return bool

CheckCertificateValuesMatchCertificateRefs() public method

Check if CertificateValues match CertificateRefs
public CheckCertificateValuesMatchCertificateRefs ( ) : bool
return bool

CheckCounterSignatures() public method

Perform XAdES checks on contained counter signatures. If couter signature is XMLDSIG, only XMLDSIG check (CheckSignature()) is done.
public CheckCounterSignatures ( XadesCheckSignatureMasks counterSignatureMask ) : bool
counterSignatureMask XadesCheckSignatureMasks Check mask applied to counter signatures
return bool

CheckCounterSignaturesReference() public method

Counter signatures should all contain a reference to the parent signature SignatureValue element
public CheckCounterSignaturesReference ( ) : bool
return bool

CheckHashDataInfoOfSignatureTimeStampPointsToSignatureValue() public method

Check if HashDataInfo of SignatureTimeStamp points to SignatureValue

CheckIfClaimedRolesOrCertifiedRolesPresentInSignerRole() public method

Check if at least ClaimedRoles or CertifiedRoles present in SignerRole

CheckObjectReferencesInCommitmentTypeIndication() public method

Check if each ObjectReference in CommitmentTypeIndication points to Reference element
public CheckObjectReferencesInCommitmentTypeIndication ( ) : bool
return bool

CheckQualifyingProperties() public method

Check that QualifyingProperties occur in one Object, check that there is only one QualifyingProperties and that signed properties occur in one QualifyingProperties element
public CheckQualifyingProperties ( ) : bool
return bool

CheckQualifyingPropertiesTarget() public method

Check if the QualifyingProperties Target attribute points to the signature element
public CheckQualifyingPropertiesTarget ( ) : bool
return bool

CheckRefsOnlyTimeStampHashDataInfos() public method

Check if all required HashDataInfos are present on RefsOnlyTimeStamp
public CheckRefsOnlyTimeStampHashDataInfos ( ) : bool
return bool

CheckRevocationValuesMatchRevocationRefs() public method

Check if RevocationValues match RevocationRefs
public CheckRevocationValuesMatchRevocationRefs ( ) : bool
return bool

CheckSameCertificate() public method

Check to see if first XMLDSIG certificate has same hashvalue as first XAdES SignatureCertificate
public CheckSameCertificate ( ) : bool
return bool

CheckSigAndRefsTimeStampHashDataInfos() public method

Check if all required HashDataInfos are present on SigAndRefsTimeStamp
public CheckSigAndRefsTimeStampHashDataInfos ( ) : bool
return bool

CheckXadesCIsXadesT() public method

Check if a XAdES-C signature is also a XAdES-T signature
public CheckXadesCIsXadesT ( ) : bool
return bool

CheckXadesXLIsXadesX() public method

Check if a XAdES-XL signature is also a XAdES-X signature
public CheckXadesXLIsXadesX ( ) : bool
return bool

CheckXmldsigSignature() public method

Check the signature of the underlying XMLDSIG signature
public CheckXmldsigSignature ( ) : bool
return bool

ComputeSignature() public method

Copy of System.Security.Cryptography.Xml.SignedXml.ComputeSignature() which will end up calling our own GetC14NDigest with a namespace prefix for all XmlDsig nodes
public ComputeSignature ( ) : void
return void

GetIdElement() public method

Overridden virtual method to be able to find the nested SignedProperties element inside of the XAdES object
public GetIdElement ( XmlDocument xmlDocument, string idValue ) : XmlElement
xmlDocument System.Xml.XmlDocument Document in which to find the Id
idValue string Value of the Id to look for
return System.Xml.XmlElement

GetXml() public method

Returns the XML representation of the this object
public GetXml ( ) : XmlElement
return System.Xml.XmlElement

LoadXml() public method

Load state from an XML element
public LoadXml ( System xmlElement ) : void
xmlElement System The XML element from which to load the XadesSignedXml state
return void

ValidateAgainstSchema() public method

Validate the XML representation of the signature against the XAdES and XMLDSIG schemas
public ValidateAgainstSchema ( ) : bool
return bool

XadesCheckSignature() public method

Additional tests for XAdES signatures. These tests focus on XMLDSIG verification and correct form of the XAdES XML structure (schema validation and completeness as defined by the XAdES standard).
Because of the fact that the XAdES library is intentionally independent of standards like TSP (RFC3161) or OCSP (RFC2560), these tests do NOT include any verification of timestamps nor OCSP responses. These checks are important and have to be done in the application built on top of the XAdES library.
Thrown when the signature is not /// a XAdES signature. SignatureStandard should be equal to /// KnownSignatureStandard.Xades. /// Use the CheckSignature method for non-XAdES signatures.
public XadesCheckSignature ( XadesCheckSignatureMasks xadesCheckSignatureMasks ) : bool
xadesCheckSignatureMasks XadesCheckSignatureMasks Bitmask to indicate which /// tests need to be done. This function will call a public virtual /// methods for each bit that has been set in this mask. /// See the XadesCheckSignatureMasks /// enum for the bitmask definitions. The virtual test method associated /// with a bit in the mask has the same name as enum value name.
return bool

XadesSignedXml() public method

Default constructor for the XadesSignedXml class
public XadesSignedXml ( ) : System
return System

XadesSignedXml() public method

Constructor for the XadesSignedXml class
public XadesSignedXml ( System signatureDocument ) : System
signatureDocument System XmlDocument used to create the instance
return System

XadesSignedXml() public method

Constructor for the XadesSignedXml class
public XadesSignedXml ( XmlElement signatureElement ) : System
signatureElement System.Xml.XmlElement XmlElement used to create the instance
return System