コード例 #1
0
        private static TransformChain GetChain(params Transform[] transforms)
        {
            TransformChain chain = new TransformChain();

            foreach (Transform transform in transforms)
            {
                chain.Add(transform);
            }
            return(chain);
        }
コード例 #2
0
ファイル: example.cs プロジェクト: zhimaqiao51/docs
        static void Main(string[] args)
        {
            //Create a URI string.
            String uri = "http://www.woodgrovebank.com/document.xml";
            // Create a Base64 transform. The input content retrieved from the
            // URI should be Base64-decoded before other processing.
            Transform base64 = new XmlDsigBase64Transform();
            //Create a transform chain and add the transform to it.
            TransformChain tc = new TransformChain();

            tc.Add(base64);
            //Create <CipherReference> information.
            CipherReference reference = new CipherReference(uri, tc);

            // Create a new CipherData object using the CipherReference information.
            // Note that you cannot assign both a CipherReference and a CipherValue
            // to a CipherData object.
            CipherData cd = new CipherData(reference);

            // Create a new EncryptedData object.
            EncryptedData ed = new EncryptedData();

            //Add an encryption method to the object.
            ed.Id = "ED";
            ed.EncryptionMethod = new EncryptionMethod("http://www.w3.org/2001/04/xmlenc#aes128-cbc");
            ed.CipherData       = cd;

            //Add key information to the object.
            KeyInfo ki = new KeyInfo();

            ki.AddClause(new KeyInfoRetrievalMethod("#EK", "http://www.w3.org/2001/04/xmlenc#EncryptedKey"));
            ed.KeyInfo = ki;

            // Create new XML document and put encrypted data into it.
            XmlDocument        doc = new XmlDocument();
            XmlElement         encryptionPropertyElement = (XmlElement)doc.CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl);
            EncryptionProperty ep = new EncryptionProperty(encryptionPropertyElement);

            ed.AddProperty(ep);

            // Output the resulting XML information into a file.
            try
            {
                string path = @"c:\test\MyTest.xml";

                File.WriteAllText(path, ed.GetXml().OuterXml);
            }
            catch (IOException e)
            {
                Console.WriteLine("File IO error. {0}", e);
            }
        }
コード例 #3
0
        public TransformSet(string name, XmlElement element)
        {
            Name = name;

            TransformChain = new TransformChain();
            foreach (XmlElement xmlElement in element.ChildNodes)
            {
                string    attribute = xmlElement.GetAttribute("Algorithm");
                Transform transform = CryptoConfig.CreateFromName(attribute) as Transform;
                if (transform != null)
                {
                    transform.LoadInnerXml(xmlElement.ChildNodes);
                    TransformChain.Add(transform);
                }
            }
        }
コード例 #4
0
        private Xades(XmlDocument document, XmlElement signatureParent)
        {
            _document        = document;
            _signatureParent = signatureParent;

            SignatureProperties = new XadesSignatureProperties();
            References          = new List <XadesReference>();

            // set defaults
            SignatureType = SignatureType.Xades;

            CanonicalizationMethod = SignedXml.XmlDsigExcC14NWithCommentsTransformUrl;
            DigestMethod           = SignedXml.XmlDsigSHA256Url;
            SignatureMethod        = SignedXml.XmlDsigRSASHA256Url;

            XadesTransformChain = new TransformChain();
            XadesTransformChain.Add(new XmlDsigExcC14NTransform());
            XadesDigestMethod = SignedXml.XmlDsigSHA256Url;
        }
コード例 #5
0
ファイル: Orient3D.cs プロジェクト: defs111/Interpolator
        public void RebuildTransformChain()
        {
            TransformChain.Clear();
            var daddy = Owner;

            while (daddy != null)
            {
                if (daddy is IOrient3D)
                {
                    TransformChain.Add(daddy as IOrient3D);
                    continue;
                }
                var orient = (IOrient3D)daddy.Children.FirstOrDefault(ch => ch is IOrient3D);
                if (orient != null)
                {
                    TransformChain.Add(orient);
                }
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            //Create a URI string.
            String uri = "http://www.woodgrovebank.com/document.xml";

            // Create a Base64 transform. The input content retrieved from the
            // URI should be Base64-decoded before other processing.
            Transform base64 = new XmlDsigBase64Transform();

            //Create a transform chain and add the transform to it.
            TransformChain tc = new TransformChain();

            tc.Add(base64);

            //Create <CipherReference> information.
            CipherReference reference = new CipherReference(uri, tc);

            // Write the CipherReference value to the console.
            Console.WriteLine("Cipher Reference data: {0}", reference.GetXml().OuterXml);
        }
コード例 #7
0
        public void FullChain()
        {
            TransformChain chain = new TransformChain();

            XmlDsigBase64Transform base64 = new XmlDsigBase64Transform();

            chain.Add(base64);
            Assert.Equal(base64, chain[0]);
            Assert.Equal(1, chain.Count);

            XmlDsigC14NTransform c14n = new XmlDsigC14NTransform();

            chain.Add(c14n);
            Assert.Equal(c14n, chain[1]);
            Assert.Equal(2, chain.Count);

            XmlDsigC14NWithCommentsTransform c14nc = new XmlDsigC14NWithCommentsTransform();

            chain.Add(c14nc);
            Assert.Equal(c14nc, chain[2]);
            Assert.Equal(3, chain.Count);

            XmlDsigEnvelopedSignatureTransform esign = new XmlDsigEnvelopedSignatureTransform();

            chain.Add(esign);
            Assert.Equal(esign, chain[3]);
            Assert.Equal(4, chain.Count);

            XmlDsigXPathTransform xpath = new XmlDsigXPathTransform();

            chain.Add(xpath);
            Assert.Equal(xpath, chain[4]);
            Assert.Equal(5, chain.Count);

            XmlDsigXsltTransform xslt = new XmlDsigXsltTransform();

            chain.Add(xslt);
            Assert.Equal(xslt, chain[5]);
            Assert.Equal(6, chain.Count);
        }