Ejemplo n.º 1
0
        public void WriteBodyToEncrypt(EncryptedData encryptedData, SymmetricAlgorithm algorithm)
        {
            encryptedData.Id = this.securityHeader.GenerateId();

            BodyContentHelper   helper           = new BodyContentHelper();
            XmlDictionaryWriter encryptingWriter = helper.CreateWriter();

            this.InnerMessage.WriteBodyContents(encryptingWriter);
            encryptedData.SetUpEncryption(algorithm, helper.ExtractResult());
            this.encryptedBodyContent = encryptedData;

            this.state = BodyState.Encrypted;
        }
Ejemplo n.º 2
0
 protected override void OnClose()
 {
     try
     {
         this.InnerMessage.Close();
     }
     finally
     {
         this.fullBodyBuffer       = null;
         this.bodyAttributes       = null;
         this.encryptedBodyContent = null;
         this.state = BodyState.Disposed;
     }
 }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
 public SendSecurityHeaderElement(string id, ISecurityElement item)
 {
     Id   = id;
     Item = item;
     MarkedForEncryption = false;
 }
Ejemplo n.º 5
0
 public void Replace(string id, ISecurityElement item)
 {
     Item = item;
     Id   = id;
 }
Ejemplo n.º 6
0
 public bool IsSameItem(ISecurityElement item)
 {
     return(Item == item || Item.Equals(item));
 }