30 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			30 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | 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<ServiceEndpoint> 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) | |||
|  |         { | |||
|  |         } | |||
|  |     } | |||
|  | } |