public void ApplyServiceSecurity(System.ServiceModel.Description.ServiceDescription description) { if (this.AuthenticationMode != PeerAuthenticationMode.None) { description.Behaviors.Add(this.credManager.CloneForTransport()); } }
public void ConfigureService(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { var host = (serviceHostBase as ServiceHost); if (host != null) { // Don't use this crappy binding var address = serviceHostBase.Description.Endpoints.First().Address; var contract = serviceHostBase.Description.Endpoints.First().Contract; // clear existing host.Description.Endpoints.Clear(); var binding = new WS2007HttpBinding(); binding.Security.Mode = SecurityMode.TransportWithMessageCredential; binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; binding.Security.Message.EstablishSecurityContext = false; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; MaxSetter.SetMaxes(binding); if (address.Uri.ToString().Contains("http://")) { address = new EndpointAddress(new Uri(address.Uri.ToString().Replace("http://", "https://"))); } var endpoint = host.AddServiceEndpoint(contract.ContractType, binding, address.Uri); host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true, HttpsGetEnabled = true }); } DisableErrorMasking.Disable(serviceHostBase); }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { channelDispatcher.ErrorHandlers.Add(new ServiceErrorHandler(this.ExceptionPolicyName)); } }
private void ApplyInstancing(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase) { System.Type serviceType = description.ServiceType; InstanceContext context = null; for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++) { ChannelDispatcher dispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher; if (dispatcher != null) { foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints) { if (!dispatcher2.IsSystemEndpoint) { DispatchRuntime dispatchRuntime = dispatcher2.DispatchRuntime; if (dispatchRuntime.InstanceProvider == null) { if (this.instanceProvider == null) { if ((serviceType == null) && (this.wellKnownSingleton == null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("InstanceSettingsMustHaveTypeOrWellKnownObject0"))); } if ((this.instanceMode != System.ServiceModel.InstanceContextMode.Single) && (this.wellKnownSingleton != null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxWellKnownNonSingleton0"))); } } else { dispatchRuntime.InstanceProvider = this.instanceProvider; } } dispatchRuntime.Type = serviceType; dispatchRuntime.InstanceContextProvider = InstanceContextProviderBase.GetProviderForMode(this.instanceMode, dispatchRuntime); if ((this.instanceMode == System.ServiceModel.InstanceContextMode.Single) && (dispatchRuntime.SingletonInstanceContext == null)) { if (context == null) { if (this.wellKnownSingleton != null) { context = new InstanceContext(serviceHostBase, this.wellKnownSingleton, true, false); } else if (this.hiddenSingleton != null) { context = new InstanceContext(serviceHostBase, this.hiddenSingleton, false, false); } else { context = new InstanceContext(serviceHostBase, false); } context.AutoClose = false; } dispatchRuntime.SingletonInstanceContext = context; } } } } } }
void IServiceBehavior.Validate(System.ServiceModel.Description.ServiceDescription service, ServiceHostBase serviceHostBase) { if (service == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("service"); } this.ValidateNotConcurrentWhenReleaseServiceInstanceOnTxComplete(service); bool singleThreaded = this.IsSingleThreaded(service); for (int i = 0; i < service.Endpoints.Count; i++) { ServiceEndpoint endpoint = service.Endpoints[i]; this.ValidateTransactionFlowRequired("ServiceHasAtLeastOneOperationWithTransactionFlowEnabled", service.Name, endpoint); this.EnsureNoOneWayTransactions(endpoint); this.ValidateNoMSMQandTransactionFlow(endpoint); ContractDescription contract = endpoint.Contract; for (int j = 0; j < contract.Operations.Count; j++) { OperationDescription operation = contract.Operations[j]; this.ValidateScopeRequiredAndAutoComplete(operation, singleThreaded, contract.Name); } this.ValidateAutoCompleteFalseRequirements(service, endpoint); } this.ValidateServiceBehaviorAttributeWithNoScopeRequired(service); this.ValidateTransactionAutoCompleteOnSessionCloseHasSession(service); }
public void AddBindingParameters( ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { channelDispatcher.ErrorHandlers.Add(errorHandler); } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { endpoint.Behaviors.Add(new SilverlightFaultEndpointBehavior()); } }
public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceHostBase is WorkflowServiceHost) { foreach (ChannelDispatcherBase base2 in serviceHostBase.ChannelDispatchers) { ChannelDispatcher dispatcher = base2 as ChannelDispatcher; if (dispatcher != null) { foreach (EndpointDispatcher dispatcher2 in dispatcher.Endpoints) { if (WorkflowServiceBehavior.IsWorkflowEndpoint(dispatcher2)) { dispatcher2.DispatchRuntime.PreserveMessage = true; foreach (DispatchOperation operation in dispatcher2.DispatchRuntime.Operations) { operation.BufferedReceiveEnabled = true; } } } } } serviceHostBase.Extensions.Add(new BufferedReceiveManager(this.MaxPendingMessagesPerChannel)); } }
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; } } } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { var errorhandlers = this.behaviorTypes.Where(t => t.GetInterfaces().Any(i=>i == typeof(IErrorHandler))).ToList(); var messageinspectors = this.behaviorTypes.Where(t => t.GetInterfaces().Any(i => i == typeof(IDispatchMessageInspector))).ToList(); foreach (ChannelDispatcher cd in serviceHostBase.ChannelDispatchers) { //add error handlers to all channel dispatchers foreach (var errorhandler in errorhandlers) { var handler = (IErrorHandler)Activator.CreateInstance(errorhandler); cd.ErrorHandlers.Add(handler); } //add message inspectors to all endpoints foreach (EndpointDispatcher ed in cd.Endpoints) { foreach (var messageinspector in messageinspectors) { var inspector = (IDispatchMessageInspector)Activator.CreateInstance(messageinspector); ed.DispatchRuntime.MessageInspectors.Add(inspector); } } } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers) { chanDisp.ErrorHandlers.Add(this); } }
void IServiceBehavior.ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase service) { if (ServiceHostingEnvironment.MultipleSiteBindingsEnabled) { this.SetEndpointAddressFilterToIgnorePort(service); } }
void IServiceBehavior.Validate(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase service) { if ((service.Description.Endpoints != null) && ServiceHostingEnvironment.MultipleSiteBindingsEnabled) { this.FailActivationIfEndpointsHaveAbsoluteAddress(service); } }
public virtual void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost; if (host != null) { string displayName = host.Activity.DisplayName; string hostReference = string.Empty; if (AspNetEnvironment.Enabled) { VirtualPathExtension extension = serviceHostBase.Extensions.Find <VirtualPathExtension>(); if ((extension != null) && (extension.VirtualPath != null)) { string str2 = (serviceDescription != null) ? serviceDescription.Name : string.Empty; string applicationVirtualPath = extension.ApplicationVirtualPath; string str4 = extension.VirtualPath.Replace("~", applicationVirtualPath + "|"); hostReference = string.Format(CultureInfo.InvariantCulture, "{0}{1}|{2}", new object[] { extension.SiteName, str4, str2 }); } } TrackingProfile trackingProfile = this.GetProfile(this.ProfileName, displayName); host.WorkflowExtensions.Add <EtwTrackingParticipant>(() => new EtwTrackingParticipant { ApplicationReference = hostReference, TrackingProfile = trackingProfile }); } }
/// <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)); } }
/// <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); } }
void AddBehaviors(ServiceDescription service) { // The philosophy here is to respect settings from configuration // At the moment, none of the settings we care about can be modified // through configuration. That may change in the future. // However, we never want to silently overwrite a user's configuration. // So we should either accept overrides or reject them, but never // silently update them. // ServiceBehaviorAttribute serviceBehavior = EnsureBehaviorAttribute(service); serviceBehavior.InstanceProvider = new ComPlusInstanceProvider(this.info); serviceBehavior.InstanceContextMode = InstanceContextMode.Single; // SHOULD: There is no reason to not allow concurrency at this level serviceBehavior.ConcurrencyMode = ConcurrencyMode.Multiple; serviceBehavior.UseSynchronizationContext = false; service.Behaviors.Add(new SecurityCookieModeValidator()); if (AspNetEnvironment.Enabled) { AspNetCompatibilityRequirementsAttribute aspNetCompatibilityRequirements = service.Behaviors.Find<AspNetCompatibilityRequirementsAttribute>(); if (aspNetCompatibilityRequirements == null) { aspNetCompatibilityRequirements = new AspNetCompatibilityRequirementsAttribute(); service.Behaviors.Add(aspNetCompatibilityRequirements); } } }
/// <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()); } }
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 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 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 ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { IErrorHandler handler = new ErrorHandler(); foreach (ChannelDispatcher chDisp in serviceHostBase.ChannelDispatchers) { if (chDisp.BindingName.Contains("WebHttpBinding")) { chDisp.ErrorHandlers.Add(handler); foreach (EndpointDispatcher epDisp in chDisp.Endpoints) { epDisp.DispatchRuntime.MessageInspectors.Add(new Authenticator()); } } } foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { if (endpoint.Binding.GetType() == typeof(WebHttpBinding)) { foreach (OperationDescription operation in endpoint.Contract.Operations) { operation.Behaviors.Add(new CustomMessageFormatter.Behavior()); } } } }
//- @ApplyDispatchBehavior -// public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { dispatcher.ErrorHandlers.Add(new ErrorHandler(serviceDescription.ServiceType)); } }
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) { ICorrelationDataSource property = endpoint.Binding.GetProperty <ICorrelationDataSource>(new BindingParameterCollection()); if (property != null) { this.ConfigureBindingDataNames(property); this.ConfigureBindingDefaultQueries(endpoint, property, true); } System.ServiceModel.Description.ServiceDescription description = endpointDispatcher.ChannelDispatcher.Host.Description; WorkflowServiceHost host = endpointDispatcher.ChannelDispatcher.Host as WorkflowServiceHost; if (host == null) { this.ScopeName = XNamespace.Get(description.Namespace).GetName(description.Name); } else { this.ScopeName = host.DurableInstancingOptions.ScopeName; } endpointDispatcher.ChannelDispatcher.ChannelInitializers.Add(this); if (this.shouldPreserveMessage) { endpointDispatcher.DispatchRuntime.PreserveMessage = true; } }
public void ConfigureService(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { var host = (serviceHostBase as ServiceHost); if (host != null) { var address = serviceHostBase.Description.Endpoints.First().Address; var contract = serviceHostBase.Description.Endpoints.First().Contract; if (address.ToString().ToLower().Contains("http")) { // clear existing host.Description.Endpoints.Clear(); // Use HTTPS (SSL) for communication var binding = new WS2007HttpBinding(SecurityMode.Transport); binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; MaxSetter.SetMaxes(binding); if (address.Uri.ToString().Contains("http://")) { var uri = address.Uri.ToString().Replace("http://", "https://"); if (ServiceHelpersConfigSection.Settings != null && ServiceHelpersConfigSection.Settings.SSLPort > 0) { uri = uri.Replace(address.Uri.Port.ToString(), ServiceHelpersConfigSection.Settings.SSLPort.ToString()); } address = new EndpointAddress(new Uri(uri)); } var endpoint = host.AddServiceEndpoint(contract.ContractType, binding, address.Uri); } } DisableErrorMasking.Disable(serviceHostBase); }
/// <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; } } } }
private void ValidateServiceBehaviorAttributeWithNoScopeRequired(System.ServiceModel.Description.ServiceDescription service) { if (!this.HasTransactedOperations(service)) { ServiceBehaviorAttribute attribute = service.Behaviors.Find <ServiceBehaviorAttribute>(); if (attribute != null) { if (attribute.TransactionTimeoutSet) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionTransactionTimeoutNeedsScope", new object[] { service.Name }))); } if (attribute.IsolationLevelSet) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionIsolationLevelNeedsScope", new object[] { service.Name }))); } if (attribute.ReleaseServiceInstanceOnTransactionCompleteSet) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionReleaseServiceInstanceOnTransactionCompleteNeedsScope", new object[] { service.Name }))); } if (attribute.TransactionAutoCompleteOnSessionCloseSet) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionTransactionAutoCompleteOnSessionCloseNeedsScope", new object[] { service.Name }))); } } } }
void IServiceBehavior.AddBindingParameters ( ServiceDescription description, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection parameters) { }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { /* IMPORTANT NOTE: * This service behavior assumes that the said operation and endpoint behaviors are stateless. * As a result it uses the same instance of the behaviors across all endpoints and operations. * All changes to these behaviors need to ensure that the STATELESSNESS IS MAINTAINED. */ lock (_syncRoot) { // Get endpoint and operation behaviors. // Install behaviors for (int i = 0; i < serviceDescription.Endpoints.Count; i++) { var endpoint = serviceDescription.Endpoints[i]; // Add operation behavior // Add the operation behavior to the endpoint for (int j = 0; j < endpoint.Contract.Operations.Count; j++) { var operation = endpoint.Contract.Operations[j]; if (operation.Behaviors.Contains(typeof(AllowAsyncService)) == false) operation.Behaviors.Add(this); } } } }
public virtual void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters) { throw new NotImplementedException(); }
// 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, System.ServiceModel.ServiceHostBase serviceHostBase) { var authenticationBehavior = serviceHostBase.Description.FindBehavior <WebAuthenticationConfigurationBehavior, WebAuthenticationConfigurationAttribute>(b => b.BaseBehavior); if (authenticationBehavior == null) throw new ServiceAuthenticationConfigurationMissingException(); var authenticationHandler = authenticationBehavior.AuthenticationHandler; var usernamePasswordValidator = authenticationBehavior.UsernamePasswordValidatorType; var authorizationBehavior = serviceHostBase.Description.FindBehavior <WebAuthorizationConfigurationBehavior, WebAuthorizationConfigurationAttribute>(b => b.BaseBehavior); Type authorizationPolicy = null; if (authorizationBehavior != null) authorizationPolicy = authorizationBehavior.AuthorizationPolicyType; foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) foreach (var endpoint in dispatcher.Endpoints) endpoint.DispatchRuntime.MessageInspectors.Add( new ServiceAuthenticationInspector( authenticationHandler, usernamePasswordValidator, authenticationBehavior.RequireSecureTransport, authenticationBehavior.Source, authorizationPolicy)); }
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); } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { var eh=new ErrorHandler(); foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers) ((ChannelDispatcher)cdb).ErrorHandlers.Insert(0, eh); }
public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { dispatcher.ErrorHandlers.Add(new WCFServiceFaultErrorHandler()); } }
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.Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { serviceHostBase.Closed += delegate { mStaContext.Dispose(); }; }
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); } }
/// <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); } }
private void ValidateConfigInstanceSettings(System.ServiceModel.Description.ServiceDescription service) { ServiceBehaviorAttribute attribute = this.EnsureBehaviorAttribute(service); foreach (ServiceEndpoint endpoint in service.Endpoints) { if ((endpoint != null) && !endpoint.InternalIsSystemEndpoint(service)) { if (endpoint.Contract.SessionMode == SessionMode.Required) { if (attribute.InstanceContextMode == InstanceContextMode.PerCall) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.InconsistentSessionRequirements()); } attribute.InstanceContextMode = InstanceContextMode.PerSession; } else { if (attribute.InstanceContextMode == InstanceContextMode.PerSession) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.InconsistentSessionRequirements()); } attribute.InstanceContextMode = InstanceContextMode.PerCall; } } } if (attribute.InstanceContextMode == InstanceContextMode.Single) { attribute.InstanceContextMode = InstanceContextMode.PerSession; } }
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints) { var type = endpoint.Contract.ContractType; foreach (OperationDescription operation in endpoint.Contract.Operations) { var method = operation.SyncMethod; foreach (MessageDescription msg in operation.Messages) { string actionname = msg.Action.ToLower(); var nosessions = method.GetCustomAttributes(typeof(NoSessionAttribute), true); if (nosessions == null || nosessions.Length == 0) SessionCallContextInitializer.NoSessions.Add(actionname, false); else SessionCallContextInitializer.NoSessions.Add(actionname, true); } } } foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers) { foreach (EndpointDispatcher endpoint in channelDispatcher.Endpoints) { //endpoint.DispatchRuntime.MessageInspectors.Add(new SessionCallContextInitializer(messageHeaderInfo)); foreach (DispatchOperation operation in endpoint.DispatchRuntime.Operations) { operation.CallContextInitializers.Add(new SessionCallContextInitializer(messageHeaderInfo)); } } } }
public override void EnsureCompatibilityRequirements(System.ServiceModel.Description.ServiceDescription description) { if (description.Behaviors.Find <AspNetCompatibilityRequirementsAttribute>() == null) { AspNetCompatibilityRequirementsAttribute item = new AspNetCompatibilityRequirementsAttribute(); description.Behaviors.Add(item); } }
void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } parameters.Add(this); }
void IServiceBehavior.AddBindingParameters(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase, Collection <ServiceEndpoint> endpoints, BindingParameterCollection parameters) { if (parameters == null) { throw FxTrace.Exception.ArgumentNull("parameters"); } parameters.Add(this.virtualPathExtension); }
void IServiceBehavior.Validate(System.ServiceModel.Description.ServiceDescription description, ServiceHostBase serviceHostBase) { if (description == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description"); } AspNetEnvironment.Current.ValidateCompatibilityRequirements(this.RequirementsMode); }
public System.ServiceModel.Description.ServiceDescription Load(ServiceHostBase host) { System.ServiceModel.Description.ServiceDescription service = new System.ServiceModel.Description.ServiceDescription(this.info.ServiceName); this.AddBehaviors(service); this.configLoader.LoadServiceDescription(host, service, this.info.ServiceElement, new Action <Uri>(host.LoadConfigurationSectionHelper)); this.ValidateConfigInstanceSettings(service); ComPlusServiceHostTrace.Trace(TraceEventType.Information, 0x50005, "TraceCodeComIntegrationServiceHostCreatedServiceEndpoint", this.info, service.Endpoints); return(service); }
public override void AddHostingBehavior(ServiceHostBase serviceHost, System.ServiceModel.Description.ServiceDescription description) { VirtualPathExtension virtualPathExtension = serviceHost.Extensions.Find <VirtualPathExtension>(); if (virtualPathExtension != null) { description.Behaviors.Add(new HostedBindingBehavior(virtualPathExtension)); } }
private void ValidateNotConcurrentWhenReleaseServiceInstanceOnTxComplete(System.ServiceModel.Description.ServiceDescription service) { ServiceBehaviorAttribute attribute = service.Behaviors.Find <ServiceBehaviorAttribute>(); if (((attribute != null) && this.HasTransactedOperations(service)) && (attribute.ReleaseServiceInstanceOnTransactionComplete && !this.IsSingleThreaded(service))) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxTransactionNonConcurrentOrReleaseServiceInstanceOnTxComplete", new object[] { service.Name }))); } }
public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost; if (host != null) { host.UnhandledExceptionAction = this.Action; } }
public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost; if (host != null) { host.WorkflowExtensions.Add(new SendMessageChannelCache(this.FactorySettings, this.ChannelSettings, this.AllowUnsafeCaching)); } }
internal static void ApplySerializationSettings(System.ServiceModel.Description.ServiceDescription description, bool ignoreExtensionDataObject, int maxItemsInObjectGraph) { foreach (ServiceEndpoint endpoint in description.Endpoints) { if (!endpoint.InternalIsSystemEndpoint(description)) { ApplySerializationSettings(endpoint, ignoreExtensionDataObject, maxItemsInObjectGraph); } } }
} // end AddBindingParameters /// <summary> /// /// </summary> /// <param name="serviceDescription"></param> /// <param name="serviceHostBase"></param> public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase) { foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers) { foreach (EndpointDispatcher endpoint in dispatcher.Endpoints) { endpoint.DispatchRuntime.MessageInspectors.Add(new AgentWCFServiceMessageInspector()); } } } // end ApplyDispatchBehavior
private bool IsSingleThreaded(System.ServiceModel.Description.ServiceDescription service) { ServiceBehaviorAttribute attribute = service.Behaviors.Find <ServiceBehaviorAttribute>(); if (attribute != null) { return(attribute.ConcurrencyMode == ConcurrencyMode.Single); } return(true); }
public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost; if (host != null) { host.IdleTimeToPersist = this.TimeToPersist; host.IdleTimeToUnload = this.TimeToUnload; } }
private bool HasTransactedOperations(System.ServiceModel.Description.ServiceDescription service) { for (int i = 0; i < service.Endpoints.Count; i++) { if (this.HasTransactedOperations(service.Endpoints[i])) { return(true); } } return(false); }
private ServiceCredentials EnsureCredentials(System.ServiceModel.Description.ServiceDescription description) { ServiceCredentials item = description.Behaviors.Find <ServiceCredentials>(); if (item == null) { item = new ServiceCredentials(); description.Behaviors.Add(item); } return(item); }
private ServiceDebugBehavior EnsureDebug(System.ServiceModel.Description.ServiceDescription description) { ServiceDebugBehavior item = description.Behaviors.Find <ServiceDebugBehavior>(); if (item == null) { item = new ServiceDebugBehavior(); description.Behaviors.Add(item); } return(item); }
private ServiceBehaviorAttribute EnsureBehaviorAttribute(System.ServiceModel.Description.ServiceDescription service) { if (service.Behaviors.Contains(typeof(ServiceBehaviorAttribute))) { return((ServiceBehaviorAttribute)service.Behaviors[typeof(ServiceBehaviorAttribute)]); } ServiceBehaviorAttribute item = new ServiceBehaviorAttribute(); service.Behaviors.Insert(0, item); return(item); }
public void Validate(System.ServiceModel.Description.ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { if (serviceDescription == null) { throw FxTrace.Exception.ArgumentNull("serviceDescription"); } if (serviceHostBase == null) { throw FxTrace.Exception.ArgumentNull("serviceHostBase"); } }