protected override EncryptedData ReadSecurityHeaderEncryptedItem(XmlDictionaryReader reader)
        {
            EncryptedData data = new EncryptedData {
                SecurityTokenSerializer = base.StandardsManager.SecurityTokenSerializer
            };

            data.ReadFrom(reader);
            return(data);
        }
Example #2
0
        protected override EncryptedData ReadSecurityHeaderEncryptedItem(XmlDictionaryReader reader, bool readXmlreferenceKeyInfoClause)
        {
            EncryptedData encryptedData = new EncryptedData();

            encryptedData.ShouldReadXmlReferenceKeyInfoClause = readXmlreferenceKeyInfoClause;
            encryptedData.SecurityTokenSerializer             = this.StandardsManager.SecurityTokenSerializer;
            encryptedData.ReadFrom(reader);
            return(encryptedData);
        }
Example #3
0
        public void ReadFrom(XmlDictionaryReader reader, long maxBufferSize)
        {
            reader.MoveToStartElement(ElementName, NamespaceUri);
            bool isReferenceParameter;

            MessageHeader.GetHeaderAttributes(reader, version, out this.actor, out this.mustUnderstand, out this.relay, out isReferenceParameter);
            this.id = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);

            reader.ReadStartElement();
            encryptedData.ReadFrom(reader, maxBufferSize);
            reader.ReadEndElement();
        }
 void DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token)
 {
     EncryptedData bodyXml = new EncryptedData();
     bodyXml.ShouldReadXmlReferenceKeyInfoClause = this.MessageDirection == MessageDirection.Output;
     bodyXml.SecurityTokenSerializer = this.StandardsManager.SecurityTokenSerializer;
     bodyXml.ReadFrom(bodyContentReader, MaxReceivedMessageSize);
     if (!bodyContentReader.EOF && bodyContentReader.NodeType != XmlNodeType.EndElement)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.GetString(SR.BadEncryptedBody)));
     }
     if (token == null)
     {
         token = ResolveKeyIdentifier(bodyXml.KeyIdentifier, this.PrimaryTokenResolver, false);
     }
     RecordEncryptionToken(token);
     using (SymmetricAlgorithm algorithm = CreateDecryptionAlgorithm(token, bodyXml.EncryptionMethod, this.AlgorithmSuite))
     {
         bodyXml.SetUpDecryption(algorithm);
         this.SecurityVerifiedMessage.SetDecryptedBody(bodyXml.GetDecryptedBuffer());
     }
 }
 private void DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token)
 {
     EncryptedData data = new EncryptedData {
         SecurityTokenSerializer = base.StandardsManager.SecurityTokenSerializer
     };
     data.ReadFrom(bodyContentReader, base.MaxReceivedMessageSize);
     if (!bodyContentReader.EOF && (bodyContentReader.NodeType != XmlNodeType.EndElement))
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.ServiceModel.SR.GetString("BadEncryptedBody")));
     }
     if (token == null)
     {
         token = ResolveKeyIdentifier(data.KeyIdentifier, base.PrimaryTokenResolver, false);
     }
     base.RecordEncryptionToken(token);
     using (SymmetricAlgorithm algorithm = CreateDecryptionAlgorithm(token, data.EncryptionMethod, base.AlgorithmSuite))
     {
         data.SetUpDecryption(algorithm);
         base.SecurityVerifiedMessage.SetDecryptedBody(data.GetDecryptedBuffer());
     }
 }
        private void DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token)
        {
            EncryptedData data = new EncryptedData {
                SecurityTokenSerializer = base.StandardsManager.SecurityTokenSerializer
            };

            data.ReadFrom(bodyContentReader, base.MaxReceivedMessageSize);
            if (!bodyContentReader.EOF && (bodyContentReader.NodeType != XmlNodeType.EndElement))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(System.ServiceModel.SR.GetString("BadEncryptedBody")));
            }
            if (token == null)
            {
                token = ResolveKeyIdentifier(data.KeyIdentifier, base.PrimaryTokenResolver, false);
            }
            base.RecordEncryptionToken(token);
            using (SymmetricAlgorithm algorithm = CreateDecryptionAlgorithm(token, data.EncryptionMethod, base.AlgorithmSuite))
            {
                data.SetUpDecryption(algorithm);
                base.SecurityVerifiedMessage.SetDecryptedBody(data.GetDecryptedBuffer());
            }
        }
Example #7
0
        void DecryptBody(XmlDictionaryReader bodyContentReader, SecurityToken token)
        {
            EncryptedData bodyXml = new EncryptedData();

            bodyXml.ShouldReadXmlReferenceKeyInfoClause = this.MessageDirection == MessageDirection.Output;
            bodyXml.SecurityTokenSerializer             = this.StandardsManager.SecurityTokenSerializer;
            bodyXml.ReadFrom(bodyContentReader, MaxReceivedMessageSize);
            if (!bodyContentReader.EOF && bodyContentReader.NodeType != XmlNodeType.EndElement)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new FormatException(SR.GetString(SR.BadEncryptedBody)));
            }
            if (token == null)
            {
                token = ResolveKeyIdentifier(bodyXml.KeyIdentifier, this.PrimaryTokenResolver, false);
            }
            RecordEncryptionToken(token);
            using (SymmetricAlgorithm algorithm = CreateDecryptionAlgorithm(token, bodyXml.EncryptionMethod, this.AlgorithmSuite))
            {
                bodyXml.SetUpDecryption(algorithm);
                this.SecurityVerifiedMessage.SetDecryptedBody(bodyXml.GetDecryptedBuffer());
            }
        }
 protected override EncryptedData ReadSecurityHeaderEncryptedItem(XmlDictionaryReader reader, bool readXmlreferenceKeyInfoClause)
 {
     EncryptedData encryptedData = new EncryptedData();
     encryptedData.ShouldReadXmlReferenceKeyInfoClause = readXmlreferenceKeyInfoClause;
     encryptedData.SecurityTokenSerializer = this.StandardsManager.SecurityTokenSerializer;
     encryptedData.ReadFrom(reader);
     return encryptedData;
 }
 protected override EncryptedData ReadSecurityHeaderEncryptedItem(XmlDictionaryReader reader)
 {
     EncryptedData data = new EncryptedData {
         SecurityTokenSerializer = base.StandardsManager.SecurityTokenSerializer
     };
     data.ReadFrom(reader);
     return data;
 }