コード例 #1
0
ファイル: XAdESSignOperation.cs プロジェクト: wjab/xadesnet
        private static XmlElement AddQualifyingPropertiesNode(ExtendedSignedXml signedXml, XmlDocument document)
        {
            var dataObject = new DataObject();
            var result     = document.CreateElement("QualifyingProperties", XadesNamespaceUrl);

            result.SetAttribute("Target", signedXml.Signature.Id);
            dataObject.Data = result.SelectNodes(".");
            signedXml.AddObject(dataObject);
            return(result);
        }
コード例 #2
0
ファイル: XadesSigner.cs プロジェクト: mihaistancu/AS4
        public void Sign()
        {
            var qualifyingProperties    = GetQualifyingProperties(Certificate);
            var qualifyingPropertiesXml = ObjectToXml.Serialize(qualifyingProperties);

            var signedXml = new ExtendedSignedXml(Xml);

            signedXml.Signature.Id = qualifyingProperties.Target;
            signedXml.SigningKey   = Certificate.GetRSAPrivateKey();
            signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;
            signedXml.SignedInfo.SignatureMethod        = SignedXml.XmlDsigRSASHA256Url;

            var documentReference = new Reference
            {
                Id   = qualifyingProperties.SignedProperties.SignedDataObjectProperties.DataObjectFormat.ObjectReference,
                Type = null,
                Uri  = ""
            };

            documentReference.AddTransform(new XmlDsigEnvelopedSignatureTransform());
            documentReference.DigestMethod = SignedXml.XmlDsigSHA256Url;
            signedXml.AddReference(documentReference);

            var signedProperties = new Reference
            {
                Type = Namespaces.SignedProperties,
                Uri  = "#" + qualifyingProperties.SignedProperties.Id
            };

            signedProperties.AddTransform(new XmlDsigExcC14NTransform());
            signedProperties.DigestMethod = SignedXml.XmlDsigSHA256Url;
            signedXml.AddReference(signedProperties);

            var dataObject = new DataObject
            {
                Data = qualifyingPropertiesXml.ChildNodes
            };

            signedXml.AddObject(dataObject);

            var certificateKeyInfo = new KeyInfo();

            certificateKeyInfo.AddClause(new KeyInfoX509Data(Certificate));
            signedXml.KeyInfo = certificateKeyInfo;

            signedXml.ComputeSignature();

            var signature = signedXml.GetXml();

            Insert(signature, Xml.DocumentElement);
        }
コード例 #3
0
        private static XmlElement CreatePropertiesNode(XmlDocument document, ExtendedSignedXml signedXml)
        {
            var dataObject = new DataObject();
            var nodeSignatureProperties = document.CreateElement("SignatureProperties", SignedXml.XmlDsigNamespaceUrl);

            nodeSignatureProperties.SetAttribute("Id", PropertiesId);
            dataObject.Data = nodeSignatureProperties.SelectNodes(".");
            signedXml.AddObject(dataObject);

            var referenceToProperties = new Reference
            {
                Uri  = "#" + PropertiesId,
                Type = ExtendedSignedXml.XmlDsigSignatureProperties
            };

            signedXml.AddReference(referenceToProperties);
            return(nodeSignatureProperties);
        }