예제 #1
0
        public void Deserialize(IReceiveContext context)
        {
            _wrappedSerializer.Deserialize(context);
            IConsumeContext <EncryptedMessageEnvelope> encryptedContext;

            context.TryGetContext(out encryptedContext);

            if (encryptedContext == null)
            {
                throw new SerializationException("Could not deserialize message.");
            }


            byte[] cipherBytes = Convert.FromBase64String(encryptedContext.Message.CipheredMessage);
            byte[] iv          = Convert.FromBase64String(encryptedContext.Message.Iv);

            var cipherStream = new EncryptedStream(cipherBytes, iv);

            using (ICryptographyService cryptographyService = new RijndaelCryptographyService(_key))
            {
                Stream clearStream = cryptographyService.Decrypt(cipherStream);

                context.SetBodyStream(clearStream);

                _wrappedSerializer.Deserialize(context);
            }
        }
예제 #2
0
 public void SetBodyStream(Stream stream)
 {
     _context.SetBodyStream(stream);
 }