Esempio n. 1
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual Document ExtendSignature(object signatureId, Document document, Document
                                                originalData, SignatureParameters parameters)
        {
            if (this.tspSource == null)
            {
                throw new ConfigurationException(ConfigurationException.MSG.CONFIGURE_TSP_SERVER);
            }

            XmlDocument    envelopedSignatureXmlDocument;
            XmlDocument    xadesDocument;
            XmlElement     signature;
            XadesSignedXml xadesSignedXml;

            xadesDocument = XmlUtils.ToXmlDocument(document);
            xadesDocument.PreserveWhitespace = true;
            xadesDocument.Load(document.OpenStream());

            xadesSignedXml = new XadesSignedXml(xadesDocument.DocumentElement); //Needed if it is a enveloped signature document

            signature = xadesSignedXml.GetIdElement(xadesDocument, (string)signatureId);

            xadesSignedXml.LoadXml(signature);

            ExtendSignatureTag(xadesSignedXml);

            envelopedSignatureXmlDocument = XmlUtils.ToXmlDocument(originalData);
            return(XmlUtils.ToDocument(envelopedSignatureXmlDocument, xadesSignedXml));
        }
        private static void InjectSignatureToOriginalDoc(XadesSignedXml signedXml, XmlDocument originalDoc)
        {
            var xmlSig = signedXml.GetXml();
            var signedDataContainer = signedXml.GetIdElement(originalDoc, "signed-data-container");

            signedDataContainer?.InsertBefore(originalDoc.ImportNode(xmlSig, true), signedDataContainer.FirstChild);
        }
Esempio n. 3
0
        public static void InjectSignatureTo(this XadesSignedXml signedXml, XmlDocument originalDoc)
        {
            var signatureElement       = signedXml.GetXml();
            var importSignatureElement = originalDoc.ImportNode(signatureElement, true);
            var signedDataContainer    = signedXml.GetIdElement(originalDoc, signedXml.SignedElementId);

            signedDataContainer.InsertBefore(importSignatureElement, signedDataContainer.FirstChild);
        }
Esempio n. 4
0
 public static void InjectSignatureToOriginalDoc(XadesSignedXml signedXml, XmlDocument originalDoc)
 {
     var xmlSig = signedXml.GetXml();
     var signedDataContainer = signedXml.GetIdElement(originalDoc, "signed-data-container");
     signedDataContainer.InsertBefore(originalDoc.ImportNode(xmlSig, true), signedDataContainer.FirstChild);
 }