StartCanonicalization() public method

public StartCanonicalization ( Stream stream, bool includeComments, string inclusivePrefixes ) : void
stream Stream
includeComments bool
inclusivePrefixes string
return void
        public void AddReference(string headerId, XmlDictionaryReader reader, XmlDictionaryWriter writer)
        {
            HashStream hashStream = this.TakeHashStream();
            writer.StartCanonicalization(hashStream, false, this.InclusivePrefixes);

            // The reader must be positioned on the start element of the header / body we want to canonicalize
            writer.WriteNode(reader, false);
            writer.EndCanonicalization();
            writer.Flush();

            // Add a reference for this block
            this.AddReference(headerId, hashStream.FlushHashAndGetValue());
        }
        public void AddReference(
            MessageHeaders headers, 
            int i,
            XmlDictionaryWriter writer, 
            string headerId, 
            bool idInserted)
        {
            HashStream hashStream = this.TakeHashStream();

            writer.StartCanonicalization(hashStream, false, this.InclusivePrefixes);
            headers.WriteStartHeader(i, writer);
            if (idInserted)
            {
                writer.WriteAttributeString(this.discoveryInfo.DiscoveryPrefix, ProtocolStrings.IdAttributeName, this.discoveryInfo.DiscoveryNamespace, headerId);
            }

            headers.WriteHeaderContents(i, writer);
            writer.WriteEndElement();
            writer.EndCanonicalization();
            writer.Flush();

            // Add a pre-digested reference for this header
            this.AddReference(headerId, hashStream.FlushHashAndGetValue());
        }
        public void WriteBodyToSignWithFragments(Stream stream, bool includeComments, string[] inclusivePrefixes, XmlDictionaryWriter writer)
        {
            IFragmentCapableXmlDictionaryWriter fragmentingWriter = (IFragmentCapableXmlDictionaryWriter) writer;

            SetBodyId();
            BufferedOutputStream fullBodyFragment = new BufferManagerOutputStream(SR.XmlBufferQuotaExceeded, 1024, int.MaxValue, this.securityHeader.StreamBufferManager);
            writer.StartCanonicalization(stream, includeComments, inclusivePrefixes);
            fragmentingWriter.StartFragment(fullBodyFragment, false);
            WriteStartInnerMessageWithId(writer);
            this.InnerMessage.WriteBodyContents(writer);
            writer.WriteEndElement();
            fragmentingWriter.EndFragment();
            writer.EndCanonicalization();

            this.fullBodyFragment = fullBodyFragment.ToArray(out this.fullBodyFragmentLength);

            this.state = BodyState.Signed;
        }
        public void WriteBodyToSignThenEncryptWithFragments(
            Stream stream, bool includeComments, string[] inclusivePrefixes,
            EncryptedData encryptedData, SymmetricAlgorithm algorithm, XmlDictionaryWriter writer)
        {
            IFragmentCapableXmlDictionaryWriter fragmentingWriter = (IFragmentCapableXmlDictionaryWriter) writer;

            SetBodyId();
            encryptedData.Id = this.securityHeader.GenerateId();

            this.startBodyFragment = new MemoryStream();
            BufferedOutputStream bodyContentFragment = new BufferManagerOutputStream(SR.XmlBufferQuotaExceeded, 1024, int.MaxValue, this.securityHeader.StreamBufferManager);
            this.endBodyFragment = new MemoryStream();

            writer.StartCanonicalization(stream, includeComments, inclusivePrefixes);

            fragmentingWriter.StartFragment(this.startBodyFragment, false);
            WriteStartInnerMessageWithId(writer);
            fragmentingWriter.EndFragment();

            fragmentingWriter.StartFragment(bodyContentFragment, true);
            this.InnerMessage.WriteBodyContents(writer);
            fragmentingWriter.EndFragment();

            fragmentingWriter.StartFragment(this.endBodyFragment, false);
            writer.WriteEndElement();
            fragmentingWriter.EndFragment();

            writer.EndCanonicalization();

            int bodyLength;
            byte[] bodyBuffer = bodyContentFragment.ToArray(out bodyLength);

            encryptedData.SetUpEncryption(algorithm, new ArraySegment<byte>(bodyBuffer, 0, bodyLength));
            this.encryptedBodyContent = encryptedData;

            this.state = BodyState.SignedThenEncrypted;
        }
 public void WriteBodyToSignWithFragments(Stream stream, bool includeComments, string[] inclusivePrefixes, XmlDictionaryWriter writer)
 {
     IFragmentCapableXmlDictionaryWriter writer2 = (IFragmentCapableXmlDictionaryWriter) writer;
     this.SetBodyId();
     BufferedOutputStream stream2 = new BufferManagerOutputStream("XmlBufferQuotaExceeded", 0x400, 0x7fffffff, BufferManager.CreateBufferManager(0L, 0x7fffffff));
     writer.StartCanonicalization(stream, includeComments, inclusivePrefixes);
     writer2.StartFragment(stream2, false);
     this.WriteStartInnerMessageWithId(writer);
     base.InnerMessage.WriteBodyContents(writer);
     writer.WriteEndElement();
     writer2.EndFragment();
     writer.EndCanonicalization();
     this.fullBodyFragment = stream2.ToArray(out this.fullBodyFragmentLength);
     this.state = BodyState.Signed;
 }
 public void WriteBodyToSignThenEncryptWithFragments(Stream stream, bool includeComments, string[] inclusivePrefixes, EncryptedData encryptedData, SymmetricAlgorithm algorithm, XmlDictionaryWriter writer)
 {
     int num;
     IFragmentCapableXmlDictionaryWriter writer2 = (IFragmentCapableXmlDictionaryWriter) writer;
     this.SetBodyId();
     encryptedData.Id = this.securityHeader.GenerateId();
     this.startBodyFragment = new MemoryStream();
     BufferedOutputStream stream2 = new BufferManagerOutputStream("XmlBufferQuotaExceeded", 0x400, 0x7fffffff, BufferManager.CreateBufferManager(0L, 0x7fffffff));
     this.endBodyFragment = new MemoryStream();
     writer.StartCanonicalization(stream, includeComments, inclusivePrefixes);
     writer2.StartFragment(this.startBodyFragment, false);
     this.WriteStartInnerMessageWithId(writer);
     writer2.EndFragment();
     writer2.StartFragment(stream2, true);
     base.InnerMessage.WriteBodyContents(writer);
     writer2.EndFragment();
     writer2.StartFragment(this.endBodyFragment, false);
     writer.WriteEndElement();
     writer2.EndFragment();
     writer.EndCanonicalization();
     byte[] array = stream2.ToArray(out num);
     encryptedData.SetUpEncryption(algorithm, new ArraySegment<byte>(array, 0, num));
     this.encryptedBodyContent = encryptedData;
     this.state = BodyState.SignedThenEncrypted;
 }
Example #7
0
        void WriteCanonicalizedBodyWithFragments(Stream canonicalStream, XmlDictionaryWriter writer)
        {
            byte[] buffer = null;
            if (this.discoveryInfo.SupportsInclusivePrefixes)
            {
                buffer = this.BufferBodyAndGetInclusivePrefixes();
            }

            using (MemoryStream bodyBufferStream = new MemoryStream())
            {
                writer.StartCanonicalization(canonicalStream, false, this.inclusivePrefixes);
                IFragmentCapableXmlDictionaryWriter fragmentingWriter = (IFragmentCapableXmlDictionaryWriter)writer;
                fragmentingWriter.StartFragment(bodyBufferStream, false);
                this.WriteBufferOrMessageBody(writer, buffer);
                fragmentingWriter.EndFragment();
                writer.EndCanonicalization();
                writer.Flush();

                this.fullBodyFragmentLength = (int)bodyBufferStream.Length;
                this.fullBodyFragment = bodyBufferStream.ToArray();
            }
        }