コード例 #1
0
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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;
        }
コード例 #5
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();
            }
        }