//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------ namespace System.ServiceModel.Security { using System; using System.IdentityModel.Protocols.WSTrust; using System.ServiceModel.Channels; using System.Xml; using RSTR = System.IdentityModel.Protocols.WSTrust.RequestSecurityTokenResponse; /// /// Defines a Body Writer that writes out the RSTR to a outgoing message. /// public class WSTrustResponseBodyWriter : BodyWriter { WSTrustResponseSerializer _serializer; RSTR _rstr; WSTrustSerializationContext _context; /// /// Initializes an instance of /// /// The Response object that can write the body contents. /// Serializer to use for serializing the RSTR. /// The of this request. /// serializer parameter is null. public WSTrustResponseBodyWriter(RSTR requestSecurityTokenResponse, WSTrustResponseSerializer serializer, WSTrustSerializationContext context) : base( true ) { if ( serializer == null ) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "serializer" ); } if ( requestSecurityTokenResponse == null ) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestSecurityTokenResponse"); } if ( context == null ) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "context" ); } _serializer = serializer; _rstr = requestSecurityTokenResponse; _context = context; } /// /// Override of the base class method. Serializes the RSTR to the outgoing stream. /// /// Writer to which the RSTR should be written. protected override void OnWriteBodyContents( XmlDictionaryWriter writer ) { _serializer.WriteXml( _rstr, writer, _context ); } } }