/// <summary> /// Verify the signature against an asymetric /// algorithm and return the result. /// </summary> /// <param name="eInvoice"></param> /// <param name="Key"></param> /// <returns></returns> /// <remarks>http://social.msdn.microsoft.com/Forums/hu-HU/netfxbcl/thread/d6a4fe9f-7d2e-419c-ab19-9e57c75ba90f</remarks> public bool CheckSignature() { XAdESSignedXml signedXml = new XAdESSignedXml(this.signedDocument); XmlNamespaceManager nsmgr = XsdSchemas.CreateXadesNamespaceManager(this.signedDocument); // Load the signature node. signedXml.LoadXml((XmlElement)this.signedDocument.SelectSingleNode("//ds:Signature", nsmgr)); // Check the signature against the passed asymetric key // and return the result. return(signedXml.CheckSignature()); }
private XAdESSignedXml SetSignatureDataObject(QualifyingPropertiesType qualifyingProperties) { var document = qualifyingProperties.ToXmlDocument(); var nsMgr = XsdSchemas.CreateXadesNamespaceManager(document); var dataObject = new DataObject(); dataObject.Id = XsdSchemas.FormatId(this.Signature.Id, "Object"); dataObject.Data = document.DocumentElement.SelectNodes(".", nsMgr); this.AddObject(dataObject); return(this); }
/// <summary> /// Gets the id element. /// </summary> /// <param name="document">The doc.</param> /// <param name="idValue">The id.</param> /// <returns></returns> public override XmlElement GetIdElement(XmlDocument document, string idValue) { if (String.IsNullOrEmpty(idValue)) { return(null); } var xmlElement = base.GetIdElement(document, idValue); var nsmgr = XsdSchemas.CreateXadesNamespaceManager(document); if (xmlElement != null) { return(XsdSchemas.FixupNamespaces(document, xmlElement)); } if (dataObjects.Count > 0) { if (this.dataObjects != null && this.dataObjects.Count > 0) { foreach (DataObject dataObject in this.dataObjects) { var nodeWithSameId = dataObject.GetXml().SelectNodes(".", nsmgr).FindNode("Id", idValue); if (nodeWithSameId != null) { return(XsdSchemas.FixupNamespaces(document, nodeWithSameId)); } } } } // Search the KeyInfo Node if (this.KeyInfo != null) { var nodeWithSameId = this.KeyInfo.GetXml().SelectNodes(".", nsmgr).FindNode("Id", idValue); if (nodeWithSameId != null) { return(XsdSchemas.FixupNamespaces(document, nodeWithSameId)); } } return(null); }