2 using System
.Collections
.Generic
;
4 using System
.ServiceModel
.Channels
;
5 using System
.ServiceModel
;
6 using System
.ServiceModel
.Security
.Tokens
;
8 namespace System
.ServiceModel
.Dispatcher
10 internal class SecurityHandler
: BaseRequestProcessorHandler
12 protected override bool ProcessRequest (MessageProcessingContext mrc
)
14 DispatchRuntime dispatch_runtime
= mrc
.OperationContext
.EndpointDispatcher
.DispatchRuntime
;
16 // FIXME: I doubt this should be done at this "handler"
17 // layer, especially considering about non-ServiceHost
18 // use of SecurityBindingElement + listener.
20 // For example there is no way to handle it in duplex
21 // dispatch callbacks.
22 if (dispatch_runtime
.ChannelDispatcher
== null)
25 Message negoResponce
= null;
26 // process WS-Trust based negotiation
27 MessageSecurityBindingSupport support
=
28 dispatch_runtime
.ChannelDispatcher
.Listener
.GetProperty
<MessageSecurityBindingSupport
> ();
29 if (support
!= null && mrc
.IncomingMessage
.Headers
.FindHeader ("Security", Constants
.WssNamespace
) < 0) {
30 CommunicationSecurityTokenAuthenticator nego
=
31 support
.TokenAuthenticator
as CommunicationSecurityTokenAuthenticator
;
33 negoResponce
= nego
.Communication
.ProcessNegotiation (mrc
.IncomingMessage
);
36 if (negoResponce
== null)
39 ReplyNegoResponse (mrc
, negoResponce
);
44 void ReplyNegoResponse (MessageProcessingContext mrc
, Message negoResponse
)
46 negoResponse
.Headers
.CopyHeadersFrom (mrc
.OperationContext
.OutgoingMessageHeaders
);
47 negoResponse
.Properties
.CopyProperties (mrc
.OperationContext
.OutgoingMessageProperties
);
48 mrc
.RequestContext
.Reply (negoResponse
, mrc
.Operation
.Parent
.ChannelDispatcher
.timeouts
.SendTimeout
);