public RelayedOnewayHttpSender(BindingContext context, Uri uri, bool transportProtectionEnabled) { Binding wSHttpBinding; this.tokenProvider = TokenProviderUtility.CreateTokenProvider(context); if (this.tokenProvider != null) { transportProtectionEnabled = true; } if (!transportProtectionEnabled) { wSHttpBinding = new WSHttpBinding(SecurityMode.None); this.via = RelayedHttpUtility.ConvertToHttpUri(uri); } else { wSHttpBinding = new WSHttpBinding(SecurityMode.Transport); this.via = RelayedHttpUtility.ConvertToHttpsUri(uri); } this.channelFactory = new ChannelFactory <IOutputChannel>(wSHttpBinding); this.channelFactory.Open(); this.channel = this.channelFactory.CreateChannel(new EndpointAddress(uri, new AddressHeader[0]), this.via); this.channel.Open(); this.OnOnline(this, EventArgs.Empty); }
internal static SecurityToken EndGetMessagingToken(this TokenProvider tokenProvider, IAsyncResult result) { Exception exception; SecurityToken securityToken; try { securityToken = tokenProvider.EndGetToken(result); } catch (Exception exception1) { if (TokenProviderUtility.HandleTokenException(exception1, out exception)) { throw exception; } throw; } return(securityToken); }
internal static IAsyncResult BeginGetMessagingToken(this TokenProvider tokenProvider, Uri namespaceAddress, string appliesTo, string action, bool bypassCache, TimeSpan timeout, AsyncCallback callback, object state) { Exception exception; IAsyncResult asyncResult; try { asyncResult = tokenProvider.BeginGetToken(namespaceAddress, appliesTo, action, bypassCache, timeout, callback, state); } catch (Exception exception1) { if (TokenProviderUtility.HandleTokenException(exception1, out exception)) { throw exception; } throw; } return(asyncResult); }
private BindingElement BuildInnerBindingElement(BindingContext context) { SocketConnectionBindingElement socketConnectionBindingElement = null; NameSettings nameSetting = context.BindingParameters.Find <NameSettings>(); NameSettings relayClientAuthenticationType = nameSetting; if (nameSetting == null) { relayClientAuthenticationType = new NameSettings(); context.BindingParameters.Add(relayClientAuthenticationType); } relayClientAuthenticationType.ServiceSettings.TransportProtection = (this.transportProtectionEnabled ? RelayTransportProtectionMode.EndToEnd : RelayTransportProtectionMode.None); relayClientAuthenticationType.ServiceSettings.RelayClientAuthenticationType = this.RelayClientAuthenticationType; relayClientAuthenticationType.ServiceSettings.IsDynamic = this.IsDynamic; TokenProvider tokenProvider = TokenProviderUtility.CreateTokenProvider(context); switch (this.relayedConnectionMode) { case TcpRelayConnectionMode.Relayed: { if (relayClientAuthenticationType.ServiceSettings.ListenerType != ListenerType.RelayedHttp) { relayClientAuthenticationType.ServiceSettings.ListenerType = ListenerType.RelayedConnection; } ConnectivitySettings connectivitySetting = context.BindingParameters.Find <ConnectivitySettings>(); HttpConnectivitySettings httpConnectivitySetting = context.BindingParameters.Find <HttpConnectivitySettings>(); socketConnectionBindingElement = new SocketConnectionBindingElement(new ConnectivityModeConnectionElement(tokenProvider, (this.transportProtectionEnabled ? SocketSecurityRole.SslClient : SocketSecurityRole.None), context, relayClientAuthenticationType, connectivitySetting, httpConnectivitySetting)); break; } case TcpRelayConnectionMode.Hybrid: { if (base.ChannelInitializationTimeout < TimeSpan.FromSeconds(60)) { base.ChannelInitializationTimeout = TimeSpan.FromSeconds(60); } relayClientAuthenticationType.ServiceSettings.ListenerType = ListenerType.DirectConnection; socketConnectionBindingElement = new SocketConnectionBindingElement(new HybridConnectionElement(context, this, relayClientAuthenticationType, tokenProvider)); break; } default: { goto case TcpRelayConnectionMode.Relayed; } } socketConnectionBindingElement.ChannelInitializationTimeout = base.ChannelInitializationTimeout; socketConnectionBindingElement.ConnectionBufferSize = base.ConnectionBufferSize; socketConnectionBindingElement.ConnectionPoolSettings.GroupName = this.ConnectionPoolSettings.GroupName; socketConnectionBindingElement.ConnectionPoolSettings.IdleTimeout = this.ConnectionPoolSettings.IdleTimeout; socketConnectionBindingElement.ConnectionPoolSettings.LeaseTimeout = this.ConnectionPoolSettings.LeaseTimeout; socketConnectionBindingElement.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = this.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint; socketConnectionBindingElement.ExposeConnectionProperty = base.ExposeConnectionProperty; socketConnectionBindingElement.HostNameComparisonMode = base.HostNameComparisonMode; socketConnectionBindingElement.InheritBaseAddressSettings = base.InheritBaseAddressSettings; socketConnectionBindingElement.ListenBacklog = this.ListenBacklog; socketConnectionBindingElement.ManualAddressing = base.ManualAddressing; socketConnectionBindingElement.MaxBufferPoolSize = this.MaxBufferPoolSize; socketConnectionBindingElement.MaxBufferSize = base.MaxBufferSize; socketConnectionBindingElement.MaxOutputDelay = base.MaxOutputDelay; socketConnectionBindingElement.MaxPendingAccepts = base.MaxPendingAccepts; socketConnectionBindingElement.MaxPendingConnections = base.MaxPendingConnections; socketConnectionBindingElement.MaxReceivedMessageSize = this.MaxReceivedMessageSize; socketConnectionBindingElement.TransferMode = base.TransferMode; socketConnectionBindingElement.TeredoEnabled = false; return(socketConnectionBindingElement); }
internal static TokenProvider CreateTokenProvider(BindingContext context) { return(TokenProviderUtility.CreateTokenProvider(context.BindingParameters.Find <TransportClientEndpointBehavior>())); }
public RelayHttpTransportChannelFactory(BindingContext context, IChannelFactory <IRequestChannel> innerChannelFactory) : base(context.Binding, innerChannelFactory) { this.innerChannelFactory = innerChannelFactory; this.tokenProvider = TokenProviderUtility.CreateTokenProvider(context); }