ToXmlDocument() public static method

public static ToXmlDocument ( Document document ) : XmlDocument
document Document
return System.Xml.XmlDocument
コード例 #1
0
ファイル: XAdESProfileBES.cs プロジェクト: ylepikhov/dssnet
        protected internal virtual Stream GetToBeSignedStream(Document document, SignatureParameters
                                                              parameters)
        {
            XmlDocument    envelopedSignatureXmlDocument;
            XadesSignedXml xadesSignedXml;

            envelopedSignatureXmlDocument = XmlUtils.ToXmlDocument(document);
            xadesSignedXml = CreateFromXmlDocument(envelopedSignatureXmlDocument);

            string uid         = ComputeDeterministicId(parameters);
            string signatureId = "sigId-" + uid;
            string signedId    = "xades-" + 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);

            return(xadesSignedXml.PreComputeSignature());
        }
コード例 #2
0
ファイル: XAdESProfileT.cs プロジェクト: ylepikhov/dssnet
        /// <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));
        }
コード例 #3
0
ファイル: XAdESProfileBES.cs プロジェクト: ylepikhov/dssnet
        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));
        }