Пример #1
0
        /// <summary>Loads a <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> state from an XML element.</summary>
        /// <param name="value">The XML element from which to load the <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> state. </param>
        /// <exception cref="T:System.ArgumentNullException">The <paramref name="value" /> parameter is <see langword="null" />. </exception>
        public void LoadXml(XmlElement value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            XmlElement element1 = value;

            this.m_id = Exml.GetAttribute(element1, "Id", "http://www.w3.org/2000/09/xmldsig#");
            if (!Exml.VerifyAttributes(element1, "Id"))
            {
                throw new CryptographicException("Invalid XML element: KeyInfo");
            }
            for (XmlNode xmlNode = element1.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling)
            {
                XmlElement element2 = xmlNode as XmlElement;
                if (element2 != null)
                {
                    string key = element2.NamespaceURI + " " + element2.LocalName;
                    if (key == "http://www.w3.org/2000/09/xmldsig# KeyValue")
                    {
                        if (!Exml.VerifyAttributes(element2, (string[])null))
                        {
                            throw new CryptographicException("Invalid XML element: KeyInfo/KeyValue");
                        }
                        foreach (XmlNode childNode in element2.ChildNodes)
                        {
                            XmlElement xmlElement = childNode as XmlElement;
                            if (xmlElement != null)
                            {
                                key = key + "/" + xmlElement.LocalName;
                                break;
                            }
                        }
                    }
                    KeyInfoClause clause = Exml.CreateFromName <KeyInfoClause>(key) ?? (KeyInfoClause) new KeyInfoNode();
                    clause.LoadXml(element2);
                    this.AddClause(clause);
                }
            }
        }
Пример #2
0
 /// <summary>Adds a <see cref="T:System.Security.Cryptography.Xml.KeyInfoClause" /> that represents a particular type of <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> information to the <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> object.</summary>
 /// <param name="clause">The <see cref="T:System.Security.Cryptography.Xml.KeyInfoClause" /> to add to the <see cref="T:System.Security.Cryptography.Xml.KeyInfo" /> object. </param>
 public void AddClause(KeyInfoClause clause)
 {
     this.m_KeyInfoClauses.Add((object)clause);
 }