public override void LoadXml(XmlElement value) {
            if (value == null)
                throw new ArgumentNullException("value");

            XmlNamespaceManager nsm = new XmlNamespaceManager(value.OwnerDocument.NameTable);
            nsm.AddNamespace("enc", EncryptedXml.XmlEncNamespaceUrl);
            nsm.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

            this.Id = Utils.GetAttribute(value, "Id", EncryptedXml.XmlEncNamespaceUrl);
            this.Type = Utils.GetAttribute(value, "Type", EncryptedXml.XmlEncNamespaceUrl);
            this.MimeType = Utils.GetAttribute(value, "MimeType", EncryptedXml.XmlEncNamespaceUrl);
            this.Encoding = Utils.GetAttribute(value, "Encoding", EncryptedXml.XmlEncNamespaceUrl);

            XmlNode encryptionMethodNode = value.SelectSingleNode("enc:EncryptionMethod", nsm);

            // EncryptionMethod
            this.EncryptionMethod = new EncryptionMethod();
            if (encryptionMethodNode != null)
                this.EncryptionMethod.LoadXml(encryptionMethodNode as XmlElement);

            // Key Info
            this.KeyInfo = new KeyInfo();
            XmlNode keyInfoNode = value.SelectSingleNode("ds:KeyInfo", nsm);
            if (keyInfoNode != null)
                this.KeyInfo.LoadXml(keyInfoNode as XmlElement);

            // CipherData
            XmlNode cipherDataNode = value.SelectSingleNode("enc:CipherData", nsm);
            if (cipherDataNode == null) 
                throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_MissingCipherData"));

            this.CipherData = new CipherData();
            this.CipherData.LoadXml(cipherDataNode as XmlElement);

            // EncryptionProperties
            XmlNode encryptionPropertiesNode = value.SelectSingleNode("enc:EncryptionProperties", nsm);
            if (encryptionPropertiesNode != null) {
                // Select the EncryptionProperty elements inside the EncryptionProperties element
                XmlNodeList encryptionPropertyNodes = encryptionPropertiesNode.SelectNodes("enc:EncryptionProperty", nsm);
                if (encryptionPropertyNodes != null) {
                    foreach (XmlNode node in encryptionPropertyNodes) {
                        EncryptionProperty ep = new EncryptionProperty();
                        ep.LoadXml(node as XmlElement);
                        this.EncryptionProperties.Add(ep);
                    }
                }
            }

            // Save away the cached value
            m_cachedXml = value;
        }
示例#2
0
        internal XmlElement GetXml(XmlDocument document)
        {
            XmlElement element = document.CreateElement("EncryptedData", "http://www.w3.org/2001/04/xmlenc#");

            if (!string.IsNullOrEmpty(this.Id))
            {
                element.SetAttribute("Id", this.Id);
            }
            if (!string.IsNullOrEmpty(this.Type))
            {
                element.SetAttribute("Type", this.Type);
            }
            if (!string.IsNullOrEmpty(this.MimeType))
            {
                element.SetAttribute("MimeType", this.MimeType);
            }
            if (!string.IsNullOrEmpty(this.Encoding))
            {
                element.SetAttribute("Encoding", this.Encoding);
            }
            if (this.EncryptionMethod != null)
            {
                element.AppendChild(this.EncryptionMethod.GetXml(document));
            }
            if (base.KeyInfo.Count > 0)
            {
                element.AppendChild(base.KeyInfo.GetXml(document));
            }
            if (this.CipherData == null)
            {
                throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_MissingCipherData"));
            }
            element.AppendChild(this.CipherData.GetXml(document));
            if (this.EncryptionProperties.Count > 0)
            {
                XmlElement newChild = document.CreateElement("EncryptionProperties", "http://www.w3.org/2001/04/xmlenc#");
                for (int i = 0; i < this.EncryptionProperties.Count; i++)
                {
                    EncryptionProperty property = this.EncryptionProperties.Item(i);
                    newChild.AppendChild(property.GetXml(document));
                }
                element.AppendChild(newChild);
            }
            return(element);
        }
 public int Add(EncryptionProperty value)
 {
     return(list.Add(value));
 }
 public void Insert(int index, EncryptionProperty value)
 {
     list.Insert(index, value);
 }
 public int Add(EncryptionProperty value)
 {
     return(_props.Add(value));
 }
 public override void LoadXml(XmlElement value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(value.OwnerDocument.NameTable);
     nsmgr.AddNamespace("enc", "http://www.w3.org/2001/04/xmlenc#");
     nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
     this.Id = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Id", "http://www.w3.org/2001/04/xmlenc#");
     this.Type = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Type", "http://www.w3.org/2001/04/xmlenc#");
     this.MimeType = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "MimeType", "http://www.w3.org/2001/04/xmlenc#");
     this.Encoding = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Encoding", "http://www.w3.org/2001/04/xmlenc#");
     XmlNode node = value.SelectSingleNode("enc:EncryptionMethod", nsmgr);
     this.EncryptionMethod = new EncryptionMethod();
     if (node != null)
     {
         this.EncryptionMethod.LoadXml(node as XmlElement);
     }
     base.KeyInfo = new KeyInfo();
     XmlNode node2 = value.SelectSingleNode("ds:KeyInfo", nsmgr);
     if (node2 != null)
     {
         base.KeyInfo.LoadXml(node2 as XmlElement);
     }
     XmlNode node3 = value.SelectSingleNode("enc:CipherData", nsmgr);
     if (node3 == null)
     {
         throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_MissingCipherData"));
     }
     this.CipherData = new CipherData();
     this.CipherData.LoadXml(node3 as XmlElement);
     XmlNode node4 = value.SelectSingleNode("enc:EncryptionProperties", nsmgr);
     if (node4 != null)
     {
         XmlNodeList list = node4.SelectNodes("enc:EncryptionProperty", nsmgr);
         if (list != null)
         {
             foreach (XmlNode node5 in list)
             {
                 EncryptionProperty property = new EncryptionProperty();
                 property.LoadXml(node5 as XmlElement);
                 this.EncryptionProperties.Add(property);
             }
         }
     }
     base.m_cachedXml = value;
 }
 public void Insert(int index, EncryptionProperty value)
 {
     this.m_props.Insert(index, value);
 }
 public void CopyTo(EncryptionProperty[] array, int index)
 {
     this.m_props.CopyTo(array, index);
 }
 public int Add(EncryptionProperty value)
 {
     return this.m_props.Add(value);
 }
示例#10
0
        public override void LoadXml(XmlElement value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            XmlNamespaceManager nsm = new XmlNamespaceManager(value.OwnerDocument.NameTable);

            nsm.AddNamespace("enc", EncryptedXml.XmlEncNamespaceUrl);
            nsm.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

            this.Id       = Utils.GetAttribute(value, "Id", EncryptedXml.XmlEncNamespaceUrl);
            this.Type     = Utils.GetAttribute(value, "Type", EncryptedXml.XmlEncNamespaceUrl);
            this.MimeType = Utils.GetAttribute(value, "MimeType", EncryptedXml.XmlEncNamespaceUrl);
            this.Encoding = Utils.GetAttribute(value, "Encoding", EncryptedXml.XmlEncNamespaceUrl);

            XmlNode encryptionMethodNode = value.SelectSingleNode("enc:EncryptionMethod", nsm);

            // EncryptionMethod
            this.EncryptionMethod = new EncryptionMethod();
            if (encryptionMethodNode != null)
            {
                this.EncryptionMethod.LoadXml(encryptionMethodNode as XmlElement);
            }

            // Key Info
            this.KeyInfo = new KeyInfo();
            XmlNode keyInfoNode = value.SelectSingleNode("ds:KeyInfo", nsm);

            if (keyInfoNode != null)
            {
                this.KeyInfo.LoadXml(keyInfoNode as XmlElement);
            }

            // CipherData
            XmlNode cipherDataNode = value.SelectSingleNode("enc:CipherData", nsm);

            if (cipherDataNode == null)
            {
                throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_MissingCipherData"));
            }

            this.CipherData = new CipherData();
            this.CipherData.LoadXml(cipherDataNode as XmlElement);

            // EncryptionProperties
            XmlNode encryptionPropertiesNode = value.SelectSingleNode("enc:EncryptionProperties", nsm);

            if (encryptionPropertiesNode != null)
            {
                // Select the EncryptionProperty elements inside the EncryptionProperties element
                XmlNodeList encryptionPropertyNodes = encryptionPropertiesNode.SelectNodes("enc:EncryptionProperty", nsm);
                if (encryptionPropertyNodes != null)
                {
                    foreach (XmlNode node in encryptionPropertyNodes)
                    {
                        EncryptionProperty ep = new EncryptionProperty();
                        ep.LoadXml(node as XmlElement);
                        this.EncryptionProperties.Add(ep);
                    }
                }
            }

            // Save away the cached value
            m_cachedXml = value;
        }
示例#11
0
		public int Add (EncryptionProperty value)
		{
			return list.Add (value);
		}
示例#12
0
		public void Remove (EncryptionProperty value)
		{
			list.Remove (value);
		}
示例#13
0
		public void Insert (int index, EncryptionProperty value)
		{
			list.Insert (index, value);
		}
示例#14
0
		public int IndexOf (EncryptionProperty value)
		{
			return list.IndexOf (value);
		}
示例#15
0
		public void CopyTo (EncryptionProperty[] array, int index)
		{
			list.CopyTo (array, index);
		}
示例#16
0
        public override void LoadXml(XmlElement value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            XmlNamespaceManager nsm = new XmlNamespaceManager(value.OwnerDocument.NameTable);

            nsm.AddNamespace("enc", EncryptedXml.XmlEncNamespaceUrl);
            nsm.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);

            Id        = Utils.GetAttribute(value, "Id", EncryptedXml.XmlEncNamespaceUrl);
            Type      = Utils.GetAttribute(value, "Type", EncryptedXml.XmlEncNamespaceUrl);
            MimeType  = Utils.GetAttribute(value, "MimeType", EncryptedXml.XmlEncNamespaceUrl);
            Encoding  = Utils.GetAttribute(value, "Encoding", EncryptedXml.XmlEncNamespaceUrl);
            Recipient = Utils.GetAttribute(value, "Recipient", EncryptedXml.XmlEncNamespaceUrl);

            XmlNode encryptionMethodNode = value.SelectSingleNode("enc:EncryptionMethod", nsm);

            // EncryptionMethod
            EncryptionMethod = new EncryptionMethod();
            if (encryptionMethodNode != null)
            {
                EncryptionMethod.LoadXml(encryptionMethodNode as XmlElement);
            }

            // Key Info
            KeyInfo = new KeyInfo();
            XmlNode keyInfoNode = value.SelectSingleNode("ds:KeyInfo", nsm);

            if (keyInfoNode != null)
            {
                KeyInfo.LoadXml(keyInfoNode as XmlElement);
            }

            // CipherData
            XmlNode cipherDataNode = value.SelectSingleNode("enc:CipherData", nsm);

            if (cipherDataNode == null)
            {
                throw new CryptographicException(SR.Cryptography_Xml_MissingCipherData);
            }

            CipherData = new CipherData();
            CipherData.LoadXml(cipherDataNode as XmlElement);

            // EncryptionProperties
            XmlNode encryptionPropertiesNode = value.SelectSingleNode("enc:EncryptionProperties", nsm);

            if (encryptionPropertiesNode != null)
            {
                // Select the EncryptionProperty elements inside the EncryptionProperties element
                XmlNodeList encryptionPropertyNodes = encryptionPropertiesNode.SelectNodes("enc:EncryptionProperty", nsm);
                if (encryptionPropertyNodes != null)
                {
                    foreach (XmlNode node in encryptionPropertyNodes)
                    {
                        EncryptionProperty ep = new EncryptionProperty();
                        ep.LoadXml(node as XmlElement);
                        EncryptionProperties.Add(ep);
                    }
                }
            }

            // CarriedKeyName
            XmlNode carriedKeyNameNode = value.SelectSingleNode("enc:CarriedKeyName", nsm);

            if (carriedKeyNameNode != null)
            {
                CarriedKeyName = carriedKeyNameNode.InnerText;
            }

            // ReferenceList
            XmlNode referenceListNode = value.SelectSingleNode("enc:ReferenceList", nsm);

            if (referenceListNode != null)
            {
                // Select the DataReference elements inside the ReferenceList element
                XmlNodeList dataReferenceNodes = referenceListNode.SelectNodes("enc:DataReference", nsm);
                if (dataReferenceNodes != null)
                {
                    foreach (XmlNode node in dataReferenceNodes)
                    {
                        DataReference dr = new DataReference();
                        dr.LoadXml(node as XmlElement);
                        ReferenceList.Add(dr);
                    }
                }
                // Select the KeyReference elements inside the ReferenceList element
                XmlNodeList keyReferenceNodes = referenceListNode.SelectNodes("enc:KeyReference", nsm);
                if (keyReferenceNodes != null)
                {
                    foreach (XmlNode node in keyReferenceNodes)
                    {
                        KeyReference kr = new KeyReference();
                        kr.LoadXml(node as XmlElement);
                        ReferenceList.Add(kr);
                    }
                }
            }

            // Save away the cached value
            _cachedXml = value;
        }
 public void AddProperty(EncryptionProperty ep)
 {
     this.EncryptionProperties.Add(ep);
 }
 public bool Contains(EncryptionProperty value)
 {
     return this.m_props.Contains(value);
 }
 public bool Contains(EncryptionProperty value)
 {
     return(m_props.Contains(value));
 }
 public int IndexOf(EncryptionProperty value)
 {
     return this.m_props.IndexOf(value);
 }
 public int IndexOf(EncryptionProperty value)
 {
     return(m_props.IndexOf(value));
 }
 public void Remove(EncryptionProperty value)
 {
     this.m_props.Remove(value);
 }
 public void Insert(int index, EncryptionProperty value)
 {
     m_props.Insert(index, value);
 }
 public void Remove(EncryptionProperty value)
 {
     _props.Remove(value);
 }
示例#25
0
		public void AddProperty (EncryptionProperty ep)
		{
			EncryptionProperties.Add (ep);
		}
 public int IndexOf(EncryptionProperty value)
 {
     return(list.IndexOf(value));
 }
        public override void LoadXml(XmlElement value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(value.OwnerDocument.NameTable);

            nsmgr.AddNamespace("enc", "http://www.w3.org/2001/04/xmlenc#");
            nsmgr.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
            this.Id        = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Id", "http://www.w3.org/2001/04/xmlenc#");
            this.Type      = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Type", "http://www.w3.org/2001/04/xmlenc#");
            this.MimeType  = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "MimeType", "http://www.w3.org/2001/04/xmlenc#");
            this.Encoding  = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Encoding", "http://www.w3.org/2001/04/xmlenc#");
            this.Recipient = System.Security.Cryptography.Xml.Utils.GetAttribute(value, "Recipient", "http://www.w3.org/2001/04/xmlenc#");
            XmlNode node = value.SelectSingleNode("enc:EncryptionMethod", nsmgr);

            this.EncryptionMethod = new EncryptionMethod();
            if (node != null)
            {
                this.EncryptionMethod.LoadXml(node as XmlElement);
            }
            base.KeyInfo = new KeyInfo();
            XmlNode node2 = value.SelectSingleNode("ds:KeyInfo", nsmgr);

            if (node2 != null)
            {
                base.KeyInfo.LoadXml(node2 as XmlElement);
            }
            XmlNode node3 = value.SelectSingleNode("enc:CipherData", nsmgr);

            if (node3 == null)
            {
                throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Xml_MissingCipherData"));
            }
            this.CipherData = new CipherData();
            this.CipherData.LoadXml(node3 as XmlElement);
            XmlNode node4 = value.SelectSingleNode("enc:EncryptionProperties", nsmgr);

            if (node4 != null)
            {
                XmlNodeList list = node4.SelectNodes("enc:EncryptionProperty", nsmgr);
                if (list != null)
                {
                    foreach (XmlNode node5 in list)
                    {
                        EncryptionProperty property = new EncryptionProperty();
                        property.LoadXml(node5 as XmlElement);
                        this.EncryptionProperties.Add(property);
                    }
                }
            }
            XmlNode node6 = value.SelectSingleNode("enc:CarriedKeyName", nsmgr);

            if (node6 != null)
            {
                this.CarriedKeyName = node6.InnerText;
            }
            XmlNode node7 = value.SelectSingleNode("enc:ReferenceList", nsmgr);

            if (node7 != null)
            {
                XmlNodeList list2 = node7.SelectNodes("enc:DataReference", nsmgr);
                if (list2 != null)
                {
                    foreach (XmlNode node8 in list2)
                    {
                        DataReference reference = new DataReference();
                        reference.LoadXml(node8 as XmlElement);
                        this.ReferenceList.Add(reference);
                    }
                }
                XmlNodeList list3 = node7.SelectNodes("enc:KeyReference", nsmgr);
                if (list3 != null)
                {
                    foreach (XmlNode node9 in list3)
                    {
                        KeyReference reference2 = new KeyReference();
                        reference2.LoadXml(node9 as XmlElement);
                        this.ReferenceList.Add(reference2);
                    }
                }
            }
            base.m_cachedXml = value;
        }
 public void Remove(EncryptionProperty value)
 {
     list.Remove(value);
 }
示例#29
0
        internal XmlElement GetXml(XmlDocument document)
        {
            // Create the EncryptedKey element
            XmlElement encryptedKeyElement = (XmlElement)document.CreateElement("EncryptedKey", EncryptedXml.XmlEncNamespaceUrl);

            // Deal with attributes
            if (!string.IsNullOrEmpty(Id))
            {
                encryptedKeyElement.SetAttribute("Id", Id);
            }
            if (!string.IsNullOrEmpty(Type))
            {
                encryptedKeyElement.SetAttribute("Type", Type);
            }
            if (!string.IsNullOrEmpty(MimeType))
            {
                encryptedKeyElement.SetAttribute("MimeType", MimeType);
            }
            if (!string.IsNullOrEmpty(Encoding))
            {
                encryptedKeyElement.SetAttribute("Encoding", Encoding);
            }
            if (!string.IsNullOrEmpty(Recipient))
            {
                encryptedKeyElement.SetAttribute("Recipient", Recipient);
            }

            // EncryptionMethod
            if (EncryptionMethod != null)
            {
                encryptedKeyElement.AppendChild(EncryptionMethod.GetXml(document));
            }

            // KeyInfo
            if (KeyInfo.Count > 0)
            {
                encryptedKeyElement.AppendChild(KeyInfo.GetXml(document));
            }

            // CipherData
            if (CipherData == null)
            {
                throw new CryptographicException(SR.Cryptography_Xml_MissingCipherData);
            }
            encryptedKeyElement.AppendChild(CipherData.GetXml(document));

            // EncryptionProperties
            if (EncryptionProperties.Count > 0)
            {
                XmlElement encryptionPropertiesElement = document.CreateElement("EncryptionProperties", EncryptedXml.XmlEncNamespaceUrl);
                for (int index = 0; index < EncryptionProperties.Count; index++)
                {
                    EncryptionProperty ep = EncryptionProperties.Item(index);
                    encryptionPropertiesElement.AppendChild(ep.GetXml(document));
                }
                encryptedKeyElement.AppendChild(encryptionPropertiesElement);
            }

            // ReferenceList
            if (ReferenceList.Count > 0)
            {
                XmlElement referenceListElement = document.CreateElement("ReferenceList", EncryptedXml.XmlEncNamespaceUrl);
                for (int index = 0; index < ReferenceList.Count; index++)
                {
                    referenceListElement.AppendChild(ReferenceList[index].GetXml(document));
                }
                encryptedKeyElement.AppendChild(referenceListElement);
            }

            // CarriedKeyName
            if (CarriedKeyName != null)
            {
                XmlElement carriedKeyNameElement = (XmlElement)document.CreateElement("CarriedKeyName", EncryptedXml.XmlEncNamespaceUrl);
                XmlText    carriedKeyNameText    = document.CreateTextNode(CarriedKeyName);
                carriedKeyNameElement.AppendChild(carriedKeyNameText);
                encryptedKeyElement.AppendChild(carriedKeyNameElement);
            }

            return(encryptedKeyElement);
        }
 public bool Contains(EncryptionProperty value)
 {
     return(list.Contains(value));
 }
示例#31
0
		public bool Contains (EncryptionProperty value)
		{
			return list.Contains (value);
		}