using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel.Description; using System.ServiceModel.Dispatcher; namespace WcfServiceAuthentication { public class AuthenticationBehavior : IServiceBehavior { public void AddBindingParameters(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { } public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher cDispatcher in serviceHostBase.ChannelDispatchers) foreach (EndpointDispatcher endpointDispatcher in cDispatcher.Endpoints) endpointDispatcher.DispatchRuntime.MessageInspectors.Add( new AuthenticationInspector()); } public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { } } }