public EndpointAddress GetAddress(ServiceHostBase host) { if (this.AddressUri == null) { string errorMessageEndpointName = ContractValidationHelper.GetErrorMessageEndpointName(this.Name); string errorMessageEndpointServiceContractName = ContractValidationHelper.GetErrorMessageEndpointServiceContractName(this.ServiceContractName); throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.MissingUriInEndpoint(errorMessageEndpointName, errorMessageEndpointServiceContractName))); } Uri addressUri = null; if (this.AddressUri.IsAbsoluteUri) { addressUri = this.AddressUri; } else { if (this.Binding == null) { string str3 = ContractValidationHelper.GetErrorMessageEndpointName(this.Name); string str4 = ContractValidationHelper.GetErrorMessageEndpointServiceContractName(this.ServiceContractName); throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.RelativeUriRequiresBinding(str3, str4, this.AddressUri))); } if (host == null) { string str5 = ContractValidationHelper.GetErrorMessageEndpointName(this.Name); string str6 = ContractValidationHelper.GetErrorMessageEndpointServiceContractName(this.ServiceContractName); throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activities.SR.RelativeUriRequiresHost(str5, str6, this.AddressUri))); } addressUri = host.MakeAbsoluteUri(this.AddressUri, this.Binding); } return new EndpointAddress(addressUri, this.Identity, new AddressHeaderCollection(this.Headers)); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { endpoint.Behaviors.Add(new SilverlightFaultEndpointBehavior()); } }
internal DefaultPerformanceCounters(ServiceHostBase serviceHost) { this.instanceName = CreateFriendlyInstanceName(serviceHost); this.Counters = new PerformanceCounter[1]; for (int i = 0; i < 1; i++) { try { PerformanceCounter defaultPerformanceCounter = PerformanceCounters.GetDefaultPerformanceCounter(this.perfCounterNames[i], this.instanceName); if (defaultPerformanceCounter != null) { this.Counters[i] = defaultPerformanceCounter; continue; } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (DiagnosticUtility.ShouldTraceError) { TraceUtility.TraceEvent(TraceEventType.Error, 0x8003b, System.ServiceModel.SR.GetString("TraceCodePerformanceCountersFailedForService"), null, exception); } } break; } }
public virtual void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { string workflowDisplayName = ""; System.ServiceModel.Activities.WorkflowServiceHost workflowServiceHost = serviceHostBase as System.ServiceModel.Activities.WorkflowServiceHost; if (null != workflowServiceHost) { workflowDisplayName = ((System.ServiceModel.Activities.WorkflowServiceHost)serviceHostBase).Activity.DisplayName; } System.ServiceModel.Activities.WorkflowServiceHost host = serviceHostBase as System.ServiceModel.Activities.WorkflowServiceHost; if (this.TrackingComponentElements != null && host != null) { foreach (TrackingComponentElement trackingComponentElement in this.TrackingComponentElements) { TrackingParticipant trackingComponent = this.CreateTrackingComponent(trackingComponentElement); if (trackingComponent != null) { if (!string.IsNullOrEmpty(trackingComponentElement.ProfileName)) { trackingComponent.TrackingProfile = this.GetProfile(trackingComponentElement.ProfileName, workflowDisplayName); } host.WorkflowExtensions.Add(trackingComponent); } else { throw new Exception(string.Format("Tracking component is not a known type: {0}", trackingComponentElement.Name)); } } } }
public void AddBindingParameters( ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { }
/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects. /// </summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The host that is currently being built.</param> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { var instanceProvider = new ServiceInstanceProvider(this.ServiceType); var implementors = from end in serviceDescription.Endpoints where end.Contract.ContractType.IsAssignableFrom(this.ServiceType) select end.Contract.Name; foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers) { ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher; if (channelDispatcher != null) { foreach (EndpointDispatcher endPoint in channelDispatcher.Endpoints) { if (implementors.Contains(endPoint.ContractName)) endPoint.DispatchRuntime.InstanceProvider = instanceProvider; } } } }
void IServiceBehavior.Validate(ServiceDescription description,ServiceHostBase host) { DurableServiceAttribute durable = new DurableServiceAttribute(); durable.SaveStateInOperationTransaction = true; description.Behaviors.Add(durable); PersistenceProviderFactory factory; if(AutoCompleteInstance) { factory = new TransactionalInstanceProviderFactory(); } else { factory = new TransactionalMemoryProviderFactory(); } PersistenceProviderBehavior persistenceBehavior = new PersistenceProviderBehavior(factory); description.Behaviors.Add(persistenceBehavior); if(TransactionRequiredAllOperations) { foreach(ServiceEndpoint endpoint in description.Endpoints) { foreach(OperationDescription operation in endpoint.Contract.Operations) { operation.Behaviors.Find<OperationBehaviorAttribute>().TransactionScopeRequired = true; } } } }
/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects. /// </summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The host that is currently being built.</param> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (var endpoint in serviceDescription.Endpoints) { RegisterContract(endpoint); } }
/// <summary> /// Provides the ability to pass custom data to binding elements to support the contract implementation. /// </summary> /// <param name="serviceDescription"> /// The service description of the service. /// </param> /// <param name="serviceHostBase"> /// The host of the service. /// </param> /// <param name="endpoints"> /// The service endpoints. /// </param> /// <param name="bindingParameters"> /// Custom objects to which binding elements have access. /// </param> public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers) { chanDisp.ErrorHandlers.Add(new ErrorHandler(this._messageFaultBuilder)); } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { channelDispatcher.ErrorHandlers.Add(new ServiceErrorHandler(this.ExceptionPolicyName)); } }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { IErrorHandler errorHandler; try { errorHandler = (IErrorHandler)Activator.CreateInstance(m_errorHandlerType, m_tracer); } catch (MissingMethodException e) { throw new ArgumentException(string.Format( "The errorHandlerType {0} must have a public constructor with single argument of type {1}", m_errorHandlerType.AssemblyQualifiedName, typeof(ITracer).AssemblyQualifiedName) , e); } catch (InvalidCastException e) { throw new ArgumentException(string.Format( "The errorHandlerType {0} must implement System.ServiceModel.Dispatcher.IErrorHandler.", m_errorHandlerType.AssemblyQualifiedName), e); } foreach (var channelDispatcherBase in serviceHostBase.ChannelDispatchers) { var channelDispatcher = channelDispatcherBase as ChannelDispatcher; if (channelDispatcher != null) { channelDispatcher.ErrorHandlers.Add(errorHandler); } } }
public virtual void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { throw new NotImplementedException(); }
internal DefaultPerformanceCounters(ServiceHostBase serviceHost) { this.instanceName = DefaultPerformanceCounters.CreateFriendlyInstanceName(serviceHost); this.Counters = new PerformanceCounter[(int)PerfCounters.TotalCounters]; for (int i = 0; i < (int)PerfCounters.TotalCounters; i++) { try { PerformanceCounter counter = PerformanceCounters.GetDefaultPerformanceCounter(this.perfCounterNames[i], this.instanceName); if (counter != null) { this.Counters[i] = counter; } else { break; } } #pragma warning suppress 56500 // covered by FxCOP catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (DiagnosticUtility.ShouldTraceError) { TraceUtility.TraceEvent(TraceEventType.Error, TraceCode.PerformanceCountersFailedForService, SR.GetString(SR.TraceCodePerformanceCountersFailedForService), null, e); } break; } } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { var eh=new ErrorHandler(); foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) ((ChannelDispatcher)cdb).ErrorHandlers.Insert(0, eh); }
// The validation process will scan each endpoint to see if it's bindings have binding elements // that are secure. These elements consist of: Transport, Asymmetric, Symmetric, // HttpsTransport, WindowsStream and SSLStream. public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { // Loop through each endpoint individually gathering their binding elements. foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { secureElementFound = false; // Retrieve the endpoint's binding element collection. BindingElementCollection bindingElements = endpoint.Binding.CreateBindingElements(); // Look to see if the binding elements collection contains any secure binding // elements. Transport, Asymmetric and Symmetric binding elements are all // derived from SecurityBindingElement. if ((bindingElements.Find<SecurityBindingElement>() != null) || (bindingElements.Find<HttpsTransportBindingElement>() != null) || (bindingElements.Find<WindowsStreamSecurityBindingElement>() != null) || (bindingElements.Find<SslStreamSecurityBindingElement>() != null)) { secureElementFound = true; } // Send a message to the system event viewer whhen an endpoint is deemed insecure. if (!secureElementFound) throw new Exception(System.DateTime.Now.ToString() + ": The endpoint \"" + endpoint.Name + "\" has no secure bindings."); } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { List<EndpointDispatcher> endpoints = serviceHostBase.ChannelDispatchers.Cast<ChannelDispatcher>().Where(cd => cd != null) .SelectMany(cd => cd.Endpoints).ToList(); endpoints.ForEach(ep => ep.DispatchRuntime.InstanceProvider = new IoCInstanceProvider(serviceDescription.ServiceType)); }
void IServiceBehavior.ApplyDispatchBehavior( ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { IErrorHandler errorHandler; try { errorHandler = (IErrorHandler)Activator.CreateInstance(errorHandlerType); } catch (MissingMethodException e) { throw new ArgumentException( "The errorHandlerType specified in the ErrorBehaviorAttribute constructor must have a public empty constructor.", e); } catch (InvalidCastException e) { throw new ArgumentException( "The errorHandlerType specified in the ErrorBehaviorAttribute constructor must implement System.ServiceModel.Dispatcher.IErrorHandler.", e); } foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers) { var channelDispatcher = channelDispatcherBase as ChannelDispatcher; channelDispatcher.ErrorHandlers.Add(errorHandler); } }
void IServiceBehavior.ApplyDispatchBehavior ( ServiceDescription description, ServiceHostBase serviceHostBase) { ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension (serviceHostBase); //Find ChannelDispatcher for Mex, and add a MexInstanceContextProvider //to it foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) { ChannelDispatcher cd = cdb as ChannelDispatcher; if (cd == null) continue; foreach (EndpointDispatcher ed in cd.Endpoints) { if (ed.ContractName == MexContractName) ed.DispatchRuntime.InstanceContextProvider = new MexInstanceContextProvider (serviceHostBase); } } if (HttpGetEnabled) { Uri uri = serviceHostBase.CreateUri ("http", HttpGetUrl); if (uri != null) sme.EnsureChannelDispatcher (true, "http", uri, HttpGetBinding); } if (HttpsGetEnabled) { Uri uri = serviceHostBase.CreateUri ("https", HttpsGetUrl); if (uri != null) sme.EnsureChannelDispatcher (true, "https", uri, HttpsGetBinding); } }
public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { dispatcher.ErrorHandlers.Add(new WCFServiceFaultErrorHandler()); } }
/// <summary> /// Adds the binding parameters. /// </summary> /// <param name="description">The description.</param> /// <param name="serviceHostBase">The service host base.</param> /// <param name="endpoints">The endpoints.</param> /// <param name="parameters">The parameters.</param> void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (throttlingBehavior != null) { ((IServiceBehavior)throttlingBehavior).AddBindingParameters(description, serviceHostBase, endpoints, parameters); } }
void IServiceBehavior.AddBindingParameters ( ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { }
internal ServiceInfo(ServiceHostBase service) { this.service = service; this.behaviors = service.Description.Behaviors; this.serviceName = service.Description.Name; this.endpoints = new EndpointInfoCollection(service.Description.Endpoints, this.ServiceName); }
/// <summary> /// Provides the ability to change run-time property values or insert custom extension objects such as exception handlers, message or parameter interceptors, security extensions, and other custom extension objects. /// </summary> /// <param name = "serviceDescription">The service description.</param> /// <param name = "serviceHostBase">The host that is currently being built.</param> public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers) { chanDisp.ErrorHandlers.Add(new LastChanceErrorHandler()); } }
private void RegisterErrorHandlerBehavior(ErrorHandlerBehavior errorHandlerBehavior, ServiceHostBase host) { if (host.Description.Behaviors.Find<ErrorHandlerBehavior>() == null) { host.Description.Behaviors.Add(errorHandlerBehavior); } }
internal static ServicePerformanceCountersBase CreateServiceCounters(ServiceHostBase serviceHost) { if (OSEnvironmentHelper.IsVistaOrGreater) { try { ServicePerformanceCountersV2 sv = new ServicePerformanceCountersV2(serviceHost); EndpointPerformanceCountersV2.EnsureCounterSet(); OperationPerformanceCountersV2.EnsureCounterSet(); return sv; } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } PerformanceCounters.Scope = PerformanceCounterScope.Off; if (DiagnosticUtility.ShouldTraceError) { TraceUtility.TraceEvent(TraceEventType.Error, 0x8003b, System.ServiceModel.SR.GetString("TraceCodePerformanceCountersFailedForService"), null, exception); } return null; } } return new ServicePerformanceCounters(serviceHost); }
//- @ApplyDispatchBehavior -// public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { dispatcher.ErrorHandlers.Add(new ErrorHandler(serviceDescription.ServiceType)); } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { channelDispatcher.ErrorHandlers.Add(errorHandler); } }
internal ListenerHandler(IListenerBinder listenerBinder, System.ServiceModel.Dispatcher.ChannelDispatcher channelDispatcher, ServiceHostBase host, ServiceThrottle throttle, IDefaultCommunicationTimeouts timeouts) { this.listenerBinder = listenerBinder; if (this.listenerBinder == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("listenerBinder"); } this.channelDispatcher = channelDispatcher; if (this.channelDispatcher == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelDispatcher"); } this.host = host; if (this.host == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("host"); } this.throttle = throttle; if (this.throttle == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("throttle"); } this.timeouts = timeouts; this.endpoints = channelDispatcher.EndpointDispatcherTable; this.acceptor = new ErrorHandlingAcceptor(listenerBinder, channelDispatcher); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw new ArgumentNullException("serviceDescription"); } if (serviceHostBase == null) { throw new ArgumentNullException("serviceHostBase"); } for (var dispatcherIndex = 0; dispatcherIndex < serviceHostBase.ChannelDispatchers.Count; dispatcherIndex++) { var dispatcher = serviceHostBase.ChannelDispatchers[dispatcherIndex]; var channelDispatcher = (ChannelDispatcher)dispatcher; for (var endpointIndex = 0; endpointIndex < channelDispatcher.Endpoints.Count; endpointIndex++) { var endpointDispatcher = channelDispatcher.Endpoints[endpointIndex]; endpointDispatcher.DispatchRuntime.InstanceProvider = new UnityInstanceProvider(this.Container, serviceDescription.ServiceType); } } }
public ServiceDurableInstanceContextProvider( ServiceHostBase serviceHostBase, bool isPercall, Type serviceType, PersistenceProviderFactory providerFactory, bool saveStateInOperationTransaction, UnknownExceptionAction unknownExceptionAction, DurableRuntimeValidator runtimeValidator, TimeSpan operationTimeout) : base(serviceHostBase, isPercall) { if (serviceType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType"); } if (providerFactory == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("providerFactory"); } if (runtimeValidator == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("runtimeValidator"); } this.serviceType = serviceType; this.providerFactory = providerFactory; this.saveStateInOperationTransaction = saveStateInOperationTransaction; this.unknownExceptionAction = unknownExceptionAction; this.runtimeValidator = runtimeValidator; this.operationTimeout = operationTimeout; }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase host, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { }
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { }
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { }
private static ServiceThrottlingBehavior GetThrottleBehavior(this ServiceHostBase host) { ServiceThrottlingBehavior throttle = host.Description.Behaviors.Find <ServiceThrottlingBehavior>(); return(throttle); }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { }
void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { }
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters) { }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { }
void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { m_SecurityBehavior.AddBindingParameters(description, serviceHostBase, endpoints, parameters); }
public SoapRouter() { ServiceHostBase host = OperationContext.Current.Host; this.extension = host.Extensions.Find <SoapRouterExtension>(); }
/// <summary> /// Provides the ability to inspect the service host and the service description to confirm that the service can run successfully. /// </summary> /// <param name="serviceDescription">The service description.</param> /// <param name="serviceHostBase">The service host that is currently being constructed.</param> public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { //Do nothing, this behavior doesn't perform any validation }
void IServiceBehavior.Validate(ServiceDescription service, ServiceHostBase host) { }
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { AutomapperConfiguration.Load(); }
protected internal override void Attach(ServiceHostBase host) { base.Attach(host); this.host = host; }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { SoapRouterExtension extension = new SoapRouterExtension(); serviceHostBase.Extensions.Add(extension); }
void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { GetBase().AddBindingParameters(serviceDescription, serviceHostBase, endpoints, bindingParameters); }
protected internal override void Detach(ServiceHostBase host) { base.Detach(host); this.host = null; }
protected override void Attach(ServiceHostBase host) { base.Attach(host); Attached = true; }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { GetBase().ApplyDispatchBehavior(serviceDescription, serviceHostBase); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { _state.CurrentStage += ", IServiceBehavior.ApplyDispatchBehavior"; }
public void Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { if (m_SubjectName != null) { switch (m_Mode) { case ServiceSecurity.Anonymous: case ServiceSecurity.BusinessToBusiness: case ServiceSecurity.Internet: { string subjectName; if (m_SubjectName != String.Empty) { subjectName = m_SubjectName; } else { subjectName = description.Endpoints[0].Address.Uri.Host; } serviceHostBase.Credentials.ServiceCertificate.SetCertificate(m_StoreLocation, m_StoreName, m_FindType, subjectName); break; } } } if (UseAspNetProviders == true) { Debug.Assert(serviceHostBase.Credentials != null); serviceHostBase.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseAspNetRoles; string applicationName; Debug.Assert(Roles.ApplicationName == Membership.ApplicationName); if (String.IsNullOrEmpty(ApplicationName)) { ApplicationName = Membership.ApplicationName; } if (String.IsNullOrEmpty(ApplicationName) || ApplicationName == "/") { if (String.IsNullOrEmpty(Assembly.GetEntryAssembly().GetName().Name)) { applicationName = AppDomain.CurrentDomain.FriendlyName; } else { applicationName = Assembly.GetEntryAssembly().GetName().Name; } } else { applicationName = ApplicationName; } Membership.ApplicationName = applicationName; Roles.ApplicationName = applicationName; if (m_Mode == ServiceSecurity.Internet) { serviceHostBase.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.MembershipProvider; } } else { Debug.Assert(m_ApplicationName == null); //Reiterate the defaults serviceHostBase.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Windows; serviceHostBase.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.UseWindowsGroups; } if (m_Mode == ServiceSecurity.Anonymous || m_Mode == ServiceSecurity.BusinessToBusiness && UseAspNetProviders == false) { serviceHostBase.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.None; } //Make it affect only when possible if (ImpersonateAll) { if (m_Mode == ServiceSecurity.Intranet || (m_Mode == ServiceSecurity.Internet && UseAspNetProviders == false)) { return; } else { ImpersonateAll = false; } } if (m_Mode == ServiceSecurity.BusinessToBusiness) { serviceHostBase.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust; } }
void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { ApplyDispatchBehavior(dispatcher); foreach (EndpointDispatcher endpointDispatcher in dispatcher.Endpoints) { foreach (DispatchOperation operation in endpointDispatcher.DispatchRuntime.Operations) { operation.CallContextInitializers.Add(new ContextReceivalCallContextInitializer()); } } } }
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { _state.CurrentStage += ", IServiceBehavior.Validate"; Assert.AreEqual(_host.ChannelDispatchers.Count, 0); }
void IServiceBehavior.ApplyDispatchBehavior( ServiceDescription description, ServiceHostBase serviceHostBase) { throw new NotImplementedException(); }
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, global::System.Collections.ObjectModel.Collection <ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { _state.CurrentStage += ", IServiceBehavior.AddBindingParameters"; bindingParameters.Add(this); }
void IServiceBehavior.Validate(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase) { }
void IServiceBehavior.Validate( ServiceDescription description, ServiceHostBase serviceHostBase) { throw new NotImplementedException(); }
// called from SvcHttpHandlerFactory's remove callback (i.e. // unloading asp.net). It closes ServiceHost, then the host // in turn closes the listener and the channels it opened. // The channel listener calls CloseServiceChannel() to stop // accepting further requests on its shutdown. public void Close() { host.Close(); host = null; }
void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase) { if (description == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("description")); } if (serviceHostBase == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serviceHostBase")); } for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++) { ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher; if ((channelDispatcher != null) && !ServiceMetadataBehavior.IsHttpGetMetadataDispatcher(description, channelDispatcher)) { foreach (EndpointDispatcher dispatcher2 in channelDispatcher.Endpoints) { DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime; dispatchRuntime.PrincipalPermissionMode = this.principalPermissionMode; if (!dispatcher2.IsSystemEndpoint) { dispatchRuntime.ImpersonateCallerForAllOperations = this.impersonateCallerForAllOperations; } if (this.roleProvider != null) { this.ApplyRoleProvider(dispatchRuntime); } if (this.isAuthorizationManagerSet || this.isExternalPoliciesSet) { this.ApplyAuthorizationPoliciesAndManager(dispatchRuntime); } } } } }