void DoDeserializeSection(XmlReader reader)
        {
            reader.MoveToContent();

            string protection_provider = null;
            string config_source       = null;
            string localName;

            while (reader.MoveToNextAttribute())
            {
                localName = reader.LocalName;
                if (localName == "configProtectionProvider")
                {
                    protection_provider = reader.Value;
                }
                else if (localName == "configSource")
                {
                    config_source = reader.Value;
                }
            }

            /* XXX this stuff shouldn't be here */
            {
                if (protection_provider != null)
                {
                    ProtectedConfigurationProvider prov = ProtectedConfiguration.GetProvider(protection_provider, true);
                    XmlDocument doc = new ConfigurationXmlDocument();

                    reader.MoveToElement();

                    doc.Load(new StringReader(reader.ReadInnerXml()));

                    XmlNode n = prov.Decrypt(doc);

                    reader = new XmlNodeReader(n);

                    SectionInformation.ProtectSection(protection_provider);

                    reader.MoveToContent();
                }
            }

            if (config_source != null)
            {
                SectionInformation.ConfigSource = config_source;
            }

            SectionInformation.SetRawXml(RawXml);
            if (SectionHandler == null)
            {
                DeserializeElement(reader, false);
            }
        }
		public override XmlNode Encrypt (XmlNode node)
		{
			XmlDocument doc = new ConfigurationXmlDocument ();
			
			doc.Load (new StringReader (node.OuterXml));

			EncryptedXml ex = new EncryptedXml (doc);

			ex.AddKeyNameMapping ("Rsa Key", GetProvider ());

			EncryptedData d = ex.Encrypt (doc.DocumentElement, "Rsa Key");

			return d.GetXml();
		}
		public override XmlNode Decrypt (XmlNode encrypted_node)
		{
			XmlDocument doc = new ConfigurationXmlDocument ();
			
			doc.Load (new StringReader (encrypted_node.OuterXml));

			EncryptedXml ex = new EncryptedXml (doc);

			ex.AddKeyNameMapping ("Rsa Key", GetProvider ());

			ex.DecryptDocument ();
			
			return doc.DocumentElement;
		}
Esempio n. 4
0
        public override XmlNode Encrypt(XmlNode node)
        {
            XmlDocument doc = new ConfigurationXmlDocument();

            doc.Load(new StringReader(node.OuterXml));

            EncryptedXml ex = new EncryptedXml(doc);

            ex.AddKeyNameMapping("Rsa Key", GetProvider());

            EncryptedData d = ex.Encrypt(doc.DocumentElement, "Rsa Key");

            return(d.GetXml());
        }
Esempio n. 5
0
        public override XmlNode Decrypt(XmlNode encrypted_node)
        {
            XmlDocument doc = new ConfigurationXmlDocument();

            doc.Load(new StringReader(encrypted_node.OuterXml));

            EncryptedXml ex = new EncryptedXml(doc);

            ex.AddKeyNameMapping("Rsa Key", GetProvider());

            ex.DecryptDocument();

            return(doc.DocumentElement);
        }
		void DoDeserializeSection (XmlReader reader)
		{
			reader.MoveToContent ();

			string protection_provider = null;
			string config_source = null;
			string localName;
			
			while (reader.MoveToNextAttribute ()) {
				localName = reader.LocalName;
				if (localName == "configProtectionProvider")
					protection_provider = reader.Value;
				else if (localName == "configSource")
					config_source = reader.Value;
			}

			/* XXX this stuff shouldn't be here */
			{
				if (protection_provider != null) {
					ProtectedConfigurationProvider prov = ProtectedConfiguration.GetProvider (protection_provider, true);
					XmlDocument doc = new ConfigurationXmlDocument ();

					reader.MoveToElement ();

					doc.Load (new StringReader (reader.ReadInnerXml ()));

					XmlNode n = prov.Decrypt (doc);

					reader = new XmlNodeReader (n);

					SectionInformation.ProtectSection (protection_provider);

					reader.MoveToContent ();
				}
			}

			if (config_source != null)
				SectionInformation.ConfigSource = config_source;
			
			SectionInformation.SetRawXml (RawXml);
			if (SectionHandler == null)
				DeserializeElement (reader, false);
		}