/// <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)); }
internal virtual Document SignDocument(Document document, SignatureParameters parameters , byte[] signatureValue) { XmlDocument envelopedSignatureXmlDocument; XadesSignedXml xadesSignedXml; envelopedSignatureXmlDocument = XmlUtils.ToXmlDocument(document); xadesSignedXml = CreateFromXmlDocument(envelopedSignatureXmlDocument); AddCertificateInfoToSignature(xadesSignedXml, parameters); string uid = ComputeDeterministicId(parameters); string signatureId = "sigId-" + uid; string signedId = "xades-" + uid; string signatureValueId = "sigValueId-" + uid; xadesSignedXml.Signature.Id = signatureId; XadesObject xadesObject = new XadesObject(); //xadesObject.Id = "XadesObject"; xadesObject.QualifyingProperties.SignedProperties.Id = signedId; xadesObject.QualifyingProperties.Target = "#" + signatureId; this.AddSignedSignatureProperties( xadesObject.QualifyingProperties.SignedProperties.SignedSignatureProperties, xadesObject.QualifyingProperties.SignedProperties.SignedDataObjectProperties, xadesObject.QualifyingProperties.UnsignedProperties.UnsignedSignatureProperties, parameters); xadesSignedXml.AddXadesObject(xadesObject); xadesSignedXml.ComputeExternalSignature(signatureValue); xadesSignedXml.SignatureValueId = signatureValueId; return(XmlUtils.ToDocument(envelopedSignatureXmlDocument, xadesSignedXml)); }