コード例 #1
0
 public void WriteHash(HashAlgorithm hash, C14NAncestralNamespaceContextManager anc, List <byte> conjuntoDados)
 {
     foreach (XmlNode childNode in ChildNodes)
     {
         CanonicalizationDispatcher.WriteHash(childNode, hash, anc, conjuntoDados);
     }
 }
コード例 #2
0
 public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
 {
     docPos = DocPosition.BeforeRootElement;
     foreach (XmlNode childNode in ChildNodes)
     {
         if (childNode.NodeType == XmlNodeType.Element)
         {
             CanonicalizationDispatcher.WriteHash(childNode, hash, DocPosition.InRootElement, anc);
             docPos = DocPosition.AfterRootElement;
         }
         else
         {
             CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc);
         }
     }
 }
コード例 #3
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            Hashtable    nsLocallyDeclared = new Hashtable();
            SortedList   nsListToRender    = new SortedList(new NamespaceSortOrder());
            SortedList   attrListToRender  = new SortedList(new AttributeSortOrder());
            UTF8Encoding utf8 = new UTF8Encoding(false);

            byte[] rgbData;

            XmlAttributeCollection attrList = Attributes;

            if (attrList != null)
            {
                foreach (XmlAttribute attr in attrList)
                {
                    if (((CanonicalXmlAttribute)attr).IsInNodeSet || Utils.IsNamespaceNode(attr) || Utils.IsXmlNamespaceNode(attr))
                    {
                        if (Utils.IsNamespaceNode(attr))
                        {
                            anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared);
                        }
                        else if (Utils.IsXmlNamespaceNode(attr))
                        {
                            anc.TrackXmlNamespaceNode(attr, nsListToRender, attrListToRender, nsLocallyDeclared);
                        }
                        else if (IsInNodeSet)
                        {
                            attrListToRender.Add(attr, null);
                        }
                    }
                }
            }

            if (!Utils.IsCommittedNamespace(this, Prefix, NamespaceURI))
            {
                string       name     = ((Prefix.Length > 0) ? "xmlns" + ":" + Prefix : "xmlns");
                XmlAttribute nsattrib = (XmlAttribute)OwnerDocument.CreateAttribute(name);
                nsattrib.Value = NamespaceURI;
                anc.TrackNamespaceNode(nsattrib, nsListToRender, nsLocallyDeclared);
            }

            if (IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
                rgbData = utf8.GetBytes("<" + Name);
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
                foreach (object attr in nsListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                foreach (object attr in attrListToRender.GetKeyList())
                {
                    (attr as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                rgbData = utf8.GetBytes(">");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }

            anc.EnterElementContext();
            anc.LoadUnrenderedNamespaces(nsLocallyDeclared);
            anc.LoadRenderedNamespaces(nsListToRender);

            XmlNodeList childNodes = ChildNodes;

            foreach (XmlNode childNode in childNodes)
            {
                CanonicalizationDispatcher.WriteHash(childNode, hash, docPos, anc);
            }

            anc.ExitElementContext();

            if (IsInNodeSet)
            {
                rgbData = utf8.GetBytes("</" + Name + ">");
                hash.TransformBlock(rgbData, 0, rgbData.Length, rgbData, 0);
            }
        }
コード例 #4
0
        public void WriteHash(HashAlgorithm hash, DocPosition docPos, AncestralNamespaceContextManager anc)
        {
            byte[]                 bytes;
            Hashtable              nsLocallyDeclared = new Hashtable();
            SortedList             nsListToRender    = new SortedList(new NamespaceSortOrder());
            SortedList             attrListToRender  = new SortedList(new AttributeSortOrder());
            UTF8Encoding           encoding          = new UTF8Encoding(false);
            XmlAttributeCollection attributes        = this.Attributes;

            if (attributes != null)
            {
                foreach (XmlAttribute attribute in attributes)
                {
                    if ((((CanonicalXmlAttribute)attribute).IsInNodeSet || System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute)) || System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
                    {
                        if (System.Security.Cryptography.Xml.Utils.IsNamespaceNode(attribute))
                        {
                            anc.TrackNamespaceNode(attribute, nsListToRender, nsLocallyDeclared);
                        }
                        else if (System.Security.Cryptography.Xml.Utils.IsXmlNamespaceNode(attribute))
                        {
                            anc.TrackXmlNamespaceNode(attribute, nsListToRender, attrListToRender, nsLocallyDeclared);
                        }
                        else if (this.IsInNodeSet)
                        {
                            attrListToRender.Add(attribute, null);
                        }
                    }
                }
            }
            if (!System.Security.Cryptography.Xml.Utils.IsCommittedNamespace(this, this.Prefix, this.NamespaceURI))
            {
                string       name = (this.Prefix.Length > 0) ? ("xmlns:" + this.Prefix) : "xmlns";
                XmlAttribute attr = this.OwnerDocument.CreateAttribute(name);
                attr.Value = this.NamespaceURI;
                anc.TrackNamespaceNode(attr, nsListToRender, nsLocallyDeclared);
            }
            if (this.IsInNodeSet)
            {
                anc.GetNamespacesToRender(this, attrListToRender, nsListToRender, nsLocallyDeclared);
                bytes = encoding.GetBytes("<" + this.Name);
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
                foreach (object obj2 in nsListToRender.GetKeyList())
                {
                    (obj2 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                foreach (object obj3 in attrListToRender.GetKeyList())
                {
                    (obj3 as CanonicalXmlAttribute).WriteHash(hash, docPos, anc);
                }
                bytes = encoding.GetBytes(">");
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            }
            anc.EnterElementContext();
            anc.LoadUnrenderedNamespaces(nsLocallyDeclared);
            anc.LoadRenderedNamespaces(nsListToRender);
            foreach (XmlNode node in this.ChildNodes)
            {
                CanonicalizationDispatcher.WriteHash(node, hash, docPos, anc);
            }
            anc.ExitElementContext();
            if (this.IsInNodeSet)
            {
                bytes = encoding.GetBytes("</" + this.Name + ">");
                hash.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
            }
        }