public T GetProperty <T>(BindingParameterCollection parameters) where T : class { BindingContext context = new BindingContext(new CustomBinding(this), parameters); return(context.GetInnerProperty <T>()); }
private RequestDelegate BuildBranch() { _logger.LogDebug("Building branch map"); IApplicationBuilder branchApp = _app.New(); foreach (Type serviceType in _serviceBuilder.Services) { System.Collections.Generic.List <IServiceDispatcher> dispatchers = _dispatcherBuilder.BuildDispatchers(serviceType); foreach (IServiceDispatcher dispatcher in dispatchers) { if (dispatcher.BaseAddress == null) { // TODO: Should we throw? Ignore? continue; } if (!(dispatcher.Binding is CustomBinding binding)) { binding = new CustomBinding(dispatcher.Binding); } if (binding.Elements.Find <HttpTransportBindingElement>() == null) { _logger.LogDebug($"Binding for address {dispatcher.BaseAddress} is not an HTTP[S] binding ao skipping"); continue; // Not an HTTP(S) dispatcher } var parameters = new BindingParameterCollection { _app }; Type supportedChannelType = null; IServiceDispatcher serviceDispatcher = null; System.Collections.Generic.IList <Type> supportedChannels = dispatcher.SupportedChannelTypes; for (int i = 0; i < supportedChannels.Count; i++) { Type channelType = supportedChannels[i]; if (channelType == typeof(IInputChannel)) { if (binding.CanBuildServiceDispatcher <IInputChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IInputChannel>(parameters, dispatcher); supportedChannelType = typeof(IInputChannel); break; } } if (channelType == typeof(IReplyChannel)) { if (binding.CanBuildServiceDispatcher <IReplyChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IReplyChannel>(parameters, dispatcher); supportedChannelType = typeof(IReplyChannel); } } if (channelType == typeof(IDuplexChannel)) { if (binding.CanBuildServiceDispatcher <IDuplexChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IDuplexChannel>(parameters, dispatcher); supportedChannelType = typeof(IDuplexChannel); } } if (channelType == typeof(IInputSessionChannel)) { if (binding.CanBuildServiceDispatcher <IInputSessionChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IInputSessionChannel>(parameters, dispatcher); supportedChannelType = typeof(IInputSessionChannel); } } if (channelType == typeof(IReplySessionChannel)) { if (binding.CanBuildServiceDispatcher <IReplySessionChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IReplySessionChannel>(parameters, dispatcher); supportedChannelType = typeof(IReplySessionChannel); } } if (channelType == typeof(IDuplexSessionChannel)) { if (binding.CanBuildServiceDispatcher <IDuplexSessionChannel>(parameters)) { serviceDispatcher = binding.BuildServiceDispatcher <IDuplexSessionChannel>(parameters, dispatcher); supportedChannelType = typeof(IDuplexSessionChannel); } } } _logger.LogInformation($"Mapping CoreWCF branch app for path {dispatcher.BaseAddress.AbsolutePath}"); branchApp.Map(dispatcher.BaseAddress.AbsolutePath, wcfApp => { IServiceScopeFactory servicesScopeFactory = wcfApp.ApplicationServices.GetRequiredService <IServiceScopeFactory>(); var requestHandler = new RequestDelegateHandler(serviceDispatcher, servicesScopeFactory); if (requestHandler.WebSocketOptions != null) { wcfApp.UseWebSockets(requestHandler.WebSocketOptions); } wcfApp.Run(requestHandler.HandleRequest); }); } } branchApp.Use(_ => { return(reqContext => { if (reqContext.Items.TryGetValue(RestorePathsDelegateItemName, out object restorePathsDelegateAsObject)) { (restorePathsDelegateAsObject as Action)?.Invoke(); } else { _logger.LogWarning("RequestContext missing delegate with key " + RestorePathsDelegateItemName); } return _next(reqContext); }); }); return(branchApp.Build()); }
public virtual IServiceDispatcher BuildServiceDispatcher <TChannel>(Uri listenUriBaseAddress, BindingParameterCollection parameters, IServiceDispatcher dispatcher) where TChannel : class, IChannel { return(BuildServiceDispatcher <TChannel>(listenUriBaseAddress, string.Empty, parameters, dispatcher)); }
public virtual IServiceDispatcher BuildServiceDispatcher <TChannel>(Uri listenUriBaseAddress, string listenUriRelativeAddress, BindingParameterCollection parameters, IServiceDispatcher dispatcher) where TChannel : class, IChannel { EnsureInvariants(); var binding = this as CustomBinding; if (binding == null) { binding = new CustomBinding(this); } BindingContext context = new BindingContext(binding, parameters, listenUriBaseAddress, listenUriRelativeAddress); IServiceDispatcher serviceDispatcher = context.BuildNextServiceDispatcher <TChannel>(dispatcher); context.ValidateBindingElementsConsumed(); // TODO: Work out how to validate security capabilities //this.ValidateSecurityCapabilities(serviceDispatcher.GetProperty<ISecurityCapabilities>(), parameters); return(serviceDispatcher); }
void ValidateSecurityCapabilities(ISecurityCapabilities runtimeSecurityCapabilities, BindingParameterCollection parameters) { ISecurityCapabilities bindingSecurityCapabilities = GetProperty <ISecurityCapabilities>(parameters); if (!SecurityCapabilities.IsEqual(bindingSecurityCapabilities, runtimeSecurityCapabilities)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new InvalidOperationException(SR.Format(SR.SecurityCapabilitiesMismatched, this))); } }
public virtual bool CanBuildServiceDispatcher <TChannel>(BindingParameterCollection parameters) where TChannel : class, IChannel { BindingContext context = new BindingContext(new CustomBinding(this), parameters); return(context.CanBuildNextServiceDispatcher <TChannel>()); }
internal void RemoveServiceDispatcher <TChannel>(MessageFilter filter, BindingParameterCollection bindingParameters) { // Don't create if it doesn't already exist as the filter can't be held by a non-existent demuxer TryGetTypedServiceDispatcher(typeof(TChannel), bindingParameters)?.RemoveDispatcher(filter); }
internal TypedChannelDemuxer GetTypedServiceDispatcher <TChannel>(BindingParameterCollection bindingParameters) { return(GetTypedServiceDispatcher(typeof(TChannel), bindingParameters)); }
internal IServiceDispatcher CreateServiceDispatcher <TChannel>(IServiceDispatcher innerDispatcher, BindingParameterCollection bindingParameters) { return(GetTypedServiceDispatcher <TChannel>(bindingParameters).AddDispatcher(innerDispatcher, new ChannelDemuxerFilter(new MatchAllMessageFilter(), 0))); }
public ReplyChannelDemuxer(BindingParameterCollection bindingParameters) : base(bindingParameters) { }
internal IServiceDispatcher CreateServiceDispatcher <TChannel>(IServiceDispatcher innerDispatcher, ChannelDemuxerFilter filter, BindingParameterCollection bindingParameters) { return(GetTypedServiceDispatcher <TChannel>(bindingParameters).AddDispatcher(innerDispatcher, filter)); }
// since the OnOuterListenerOpen method will be called for every outer listener and we will open // the inner listener only once, we need to ensure that all the outer listeners wait till the // inner listener is opened. public DatagramChannelDemuxer(BindingParameterCollection bindingParameters) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = bindingParameters.Find <IChannelDemuxFailureHandler>(); }
public DuplexSessionChannelDemuxer(BindingParameterCollection bindingParameters) //, TimeSpan peekTimeout, int maxPendingSessions) : base(bindingParameters) //, peekTimeout, maxPendingSessions) { }
public SessionChannelDemuxer(BindingParameterCollection bindingParameters)//, TimeSpan peekTimeout, int maxPendingSessions) { _filterTable = new MessageFilterTable <IServiceDispatcher>(); DemuxFailureHandler = bindingParameters.Find <IChannelDemuxFailureHandler>(); }
internal static AuthenticationSchemes GetEffectiveAuthenticationSchemes(AuthenticationSchemes currentAuthenticationSchemes, BindingParameterCollection bindingParameters) { if (bindingParameters == null) { return(currentAuthenticationSchemes); } AuthenticationSchemes hostSupportedAuthenticationSchemes; if (!AuthenticationSchemesBindingParameter.TryExtract(bindingParameters, out hostSupportedAuthenticationSchemes)) { return(currentAuthenticationSchemes); } // TODO: Add logic for Metadata endpoints to inherit authentication scheme of host. This might not be necessary, needs more thought. //if (currentAuthenticationSchemes == AuthenticationSchemes.None || // (AspNetEnvironment.Current.IsMetadataListener(bindingParameters) && // currentAuthenticationSchemes == AuthenticationSchemes.Anonymous && // hostSupportedAuthenticationSchemes.IsNotSet(AuthenticationSchemes.Anonymous))) //{ // //Inherit authentication schemes from host. // //This logic of inheriting from the host for anonymous MEX endpoints was previously implemented in HostedAspNetEnvironment.ValidateHttpSettings. // //We moved it here to maintain the pre-multi-auth behavior. (see CSDMain 183553) // if (!hostSupportedAuthenticationSchemes.IsSingleton() && // hostSupportedAuthenticationSchemes.IsSet(AuthenticationSchemes.Anonymous) && // AspNetEnvironment.Current.AspNetCompatibilityEnabled && // AspNetEnvironment.Current.IsSimpleApplicationHost && // AspNetEnvironment.Current.IsWindowsAuthenticationConfigured()) // { // // Remove Anonymous if ASP.Net authentication mode is Windows (Asp.Net would not allow anonymous requests in this case anyway) // hostSupportedAuthenticationSchemes ^= AuthenticationSchemes.Anonymous; // } // return hostSupportedAuthenticationSchemes; //} //else //{ //build intersection between AuthenticationSchemes supported on the HttpTransportbidningELement and ServiceHost/IIS return(currentAuthenticationSchemes & hostSupportedAuthenticationSchemes); //} }