internal ConnectionOrientedTransportChannelFactory(ConnectionOrientedTransportBindingElement bindingElement, BindingContext context, string connectionPoolGroupName, TimeSpan idleTimeout, int maxOutboundConnectionsPerEndpoint, bool supportsImpersonationDuringAsyncOpen) : base(bindingElement, context) { if ((bindingElement.TransferMode == System.ServiceModel.TransferMode.Buffered) && (bindingElement.MaxReceivedMessageSize > 0x7fffffffL)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("bindingElement.MaxReceivedMessageSize", System.ServiceModel.SR.GetString("MaxReceivedMessageSizeMustBeInIntegerRange"))); } this.connectionBufferSize = bindingElement.ConnectionBufferSize; this.connectionPoolGroupName = connectionPoolGroupName; this.exposeConnectionProperty = bindingElement.ExposeConnectionProperty; this.idleTimeout = idleTimeout; this.maxBufferSize = bindingElement.MaxBufferSize; this.maxOutboundConnectionsPerEndpoint = maxOutboundConnectionsPerEndpoint; this.maxOutputDelay = bindingElement.MaxOutputDelay; this.transferMode = bindingElement.TransferMode; Collection <StreamUpgradeBindingElement> collection = context.BindingParameters.FindAll <StreamUpgradeBindingElement>(); if (collection.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleStreamUpgradeProvidersInParameters"))); } if ((collection.Count == 1) && this.SupportsUpgrade(collection[0])) { this.upgrade = collection[0].BuildClientStreamUpgradeProvider(context); context.BindingParameters.Remove <StreamUpgradeBindingElement>(); this.securityCapabilities = collection[0].GetProperty <ISecurityCapabilities>(context); this.flowIdentity = supportsImpersonationDuringAsyncOpen; } }
public ClientFramingDuplexSessionChannel(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool, bool exposeConnectionProperty, bool flowIdentity) : base(factory, settings, remoteAddresss, via, exposeConnectionProperty) { this.settings = settings; base.MessageEncoder = settings.MessageEncoderFactory.CreateSessionEncoder(); this.upgrade = settings.Upgrade; this.flowIdentity = flowIdentity; this.connectionPoolHelper = new DuplexConnectionPoolHelper(this, connectionPool, connectionInitiator); }
public StreamedFramingRequestChannel(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool) : base(factory, remoteAddresss, via, settings.ManualAddressing) { this.settings = settings; this.connectionInitiator = connectionInitiator; this.connectionPool = connectionPool; this.messageEncoder = settings.MessageEncoderFactory.Encoder; this.upgrade = settings.Upgrade; }
public StreamedFramingRequestChannel(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool) : base(factory, remoteAddresss, via, settings.ManualAddressing) { this.settings = settings; this.connectionInitiator = connectionInitiator; this.connectionPool = connectionPool; this.messageEncoder = settings.MessageEncoderFactory.Encoder; this.upgrade = settings.Upgrade; }
protected override void OnOpen(TimeSpan timeout) { StreamUpgradeProvider upgrade = this.Upgrade; if (upgrade != null) { upgrade.Open(timeout); } }
protected override void OnOpen(TimeSpan timeout) { StreamUpgradeProvider localUpgrade = Upgrade; if (localUpgrade != null) { localUpgrade.Open(timeout); } }
protected internal override async Task OnOpenAsync(TimeSpan timeout) { StreamUpgradeProvider localUpgrade = this.Upgrade; if (localUpgrade != null) { await((IAsyncCommunicationObject)localUpgrade).OpenAsync(timeout); } }
protected override void OnAbort() { StreamUpgradeProvider localUpgrade = GetUpgrade(); if (localUpgrade != null) { localUpgrade.Abort(); } base.OnAbort(); }
protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { StreamUpgradeProvider upgrade = this.Upgrade; if (upgrade != null) { return(new ChainedOpenAsyncResult(timeout, callback, state, new ChainedBeginHandler(this.OnBeginOpen), new ChainedEndHandler(this.OnEndOpen), new ICommunicationObject[] { upgrade })); } return(base.OnBeginOpen(timeout, callback, state)); }
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { StreamUpgradeProvider upgrade = this.GetUpgrade(); if (upgrade != null) { return(new ChainedCloseAsyncResult(timeout, callback, state, new ChainedBeginHandler(this.OnBeginClose), new ChainedEndHandler(this.OnEndClose), new ICommunicationObject[] { upgrade })); } return(new ChainedCloseAsyncResult(timeout, callback, state, new ChainedBeginHandler(this.OnBeginClose), new ChainedEndHandler(this.OnEndClose), new ICommunicationObject[0])); }
protected override void OnAbort() { StreamUpgradeProvider upgrade = this.GetUpgrade(); if (upgrade != null) { upgrade.Abort(); } base.OnAbort(); }
protected ConnectionOrientedTransportChannelListener(ConnectionOrientedTransportBindingElement bindingElement, BindingContext context) : base(bindingElement, context, bindingElement.HostNameComparisonMode) { if (bindingElement.TransferMode == TransferMode.Buffered) { if (bindingElement.MaxReceivedMessageSize > int.MaxValue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("bindingElement.MaxReceivedMessageSize", SR.GetString(SR.MaxReceivedMessageSizeMustBeInIntegerRange))); } if (bindingElement.MaxBufferSize != bindingElement.MaxReceivedMessageSize) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement", SR.GetString(SR.MaxBufferSizeMustMatchMaxReceivedMessageSize)); } } else { if (bindingElement.MaxBufferSize > bindingElement.MaxReceivedMessageSize) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("bindingElement", SR.GetString(SR.MaxBufferSizeMustNotExceedMaxReceivedMessageSize)); } } this.connectionBufferSize = bindingElement.ConnectionBufferSize; this.exposeConnectionProperty = bindingElement.ExposeConnectionProperty; this.InheritBaseAddressSettings = bindingElement.InheritBaseAddressSettings; this.channelInitializationTimeout = bindingElement.ChannelInitializationTimeout; this.maxBufferSize = bindingElement.MaxBufferSize; this.maxPendingConnections = bindingElement.MaxPendingConnections; this.maxOutputDelay = bindingElement.MaxOutputDelay; this.maxPendingAccepts = bindingElement.MaxPendingAccepts; this.transferMode = bindingElement.TransferMode; Collection <StreamUpgradeBindingElement> upgradeBindingElements = context.BindingParameters.FindAll <StreamUpgradeBindingElement>(); if (upgradeBindingElements.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleStreamUpgradeProvidersInParameters))); } else if ((upgradeBindingElements.Count == 1) && this.SupportsUpgrade(upgradeBindingElements[0])) { this.upgrade = upgradeBindingElements[0].BuildServerStreamUpgradeProvider(context); this.ownUpgrade = true; context.BindingParameters.Remove <StreamUpgradeBindingElement>(); this.securityCapabilities = upgradeBindingElements[0].GetProperty <ISecurityCapabilities>(context); } }
protected override void OnOpen(TimeSpan timeout) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); base.OnOpen(timeout); StreamUpgradeProvider localUpgrade = this.Upgrade; if (localUpgrade != null) { localUpgrade.Open(timeoutHelper.RemainingTime()); } }
public bool TransferUpgrade(StreamUpgradeProvider upgrade) { lock (base.ThisLock) { if (base.State != CommunicationState.Opened) { return(false); } this.upgrade = upgrade; return(true); } }
public static FramingConnectionDuplexSession CreateSession(FramingDuplexSessionChannel channel, StreamUpgradeProvider upgrade) { StreamSecurityUpgradeProvider security = upgrade as StreamSecurityUpgradeProvider; if (security == null) { return(new FramingConnectionDuplexSession(channel)); } throw ExceptionHelper.PlatformNotSupported("SecureConnectionDuplexSession is not supported."); }
protected override IAsyncResult OnBeginOpen(TimeSpan timeout, AsyncCallback callback, object state) { StreamUpgradeProvider localUpgrade = this.Upgrade; if (localUpgrade != null) { return(new ChainedOpenAsyncResult(timeout, callback, state, base.OnBeginOpen, base.OnEndOpen, localUpgrade)); } else { return(base.OnBeginOpen(timeout, callback, state)); } }
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { StreamUpgradeProvider localUpgrade = GetUpgrade(); if (localUpgrade != null) { return(new ChainedCloseAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose, localUpgrade)); } else { return(new ChainedCloseAsyncResult(timeout, callback, state, base.OnBeginClose, base.OnEndClose)); } }
public static FramingConnectionDuplexSession CreateSession(FramingDuplexSessionChannel channel, StreamUpgradeProvider upgrade) { StreamSecurityUpgradeProvider security = upgrade as StreamSecurityUpgradeProvider; if (security == null) { return(new FramingConnectionDuplexSession(channel)); } else { return(new SecureConnectionDuplexSession(channel)); } }
private StreamUpgradeProvider GetUpgrade() { StreamUpgradeProvider upgrade = null; lock (base.ThisLock) { if (this.ownUpgrade) { upgrade = this.upgrade; this.ownUpgrade = false; } } return(upgrade); }
StreamUpgradeProvider GetUpgrade() { StreamUpgradeProvider result = null; lock (ThisLock) { if (this.ownUpgrade) { result = this.upgrade; this.ownUpgrade = false; } } return(result); }
protected override void OnClose(TimeSpan timeout) { StreamUpgradeProvider upgrade = this.GetUpgrade(); if (upgrade != null) { TimeoutHelper helper = new TimeoutHelper(timeout); upgrade.Close(helper.RemainingTime()); base.OnClose(helper.RemainingTime()); } else { base.OnClose(timeout); } }
protected override void OnClose(TimeSpan timeout) { StreamUpgradeProvider localUpgrade = GetUpgrade(); if (localUpgrade != null) { TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); localUpgrade.Close(timeoutHelper.RemainingTime()); base.OnClose(timeoutHelper.RemainingTime()); } else { base.OnClose(timeout); } }
public ServerFramingDuplexSessionChannel(ConnectionOrientedTransportChannelListener channelListener, ServerSessionPreambleConnectionReader preambleReader, EndpointAddress localAddress, bool exposeConnectionProperty, ConnectionDemuxer connectionDemuxer) : base(channelListener, localAddress, preambleReader.Via, exposeConnectionProperty) { this.channelListener = channelListener; this.connectionDemuxer = connectionDemuxer; base.Connection = preambleReader.Connection; this.decoder = preambleReader.Decoder; this.connectionBuffer = preambleReader.connectionBuffer; this.offset = preambleReader.BufferOffset; this.size = preambleReader.BufferSize; this.rawConnection = preambleReader.RawConnection; StreamUpgradeProvider upgrade = channelListener.Upgrade; if (upgrade != null) { this.channelBindingProvider = upgrade.GetProperty<IStreamUpgradeChannelBindingProvider>(); this.upgradeAcceptor = upgrade.CreateUpgradeAcceptor(); } }
internal ConnectionOrientedTransportChannelFactory( ConnectionOrientedTransportBindingElement bindingElement, BindingContext context, string connectionPoolGroupName, TimeSpan idleTimeout, int maxOutboundConnectionsPerEndpoint, bool supportsImpersonationDuringAsyncOpen) : base(bindingElement, context) { if (bindingElement.TransferMode == TransferMode.Buffered && bindingElement.MaxReceivedMessageSize > int.MaxValue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("bindingElement.MaxReceivedMessageSize", SR.MaxReceivedMessageSizeMustBeInIntegerRange)); } _connectionBufferSize = bindingElement.ConnectionBufferSize; _connectionPoolGroupName = connectionPoolGroupName; _exposeConnectionProperty = bindingElement.ExposeConnectionProperty; _idleTimeout = idleTimeout; _maxBufferSize = bindingElement.MaxBufferSize; _maxOutboundConnectionsPerEndpoint = maxOutboundConnectionsPerEndpoint; _maxOutputDelay = bindingElement.MaxOutputDelay; _transferMode = bindingElement.TransferMode; Collection <StreamUpgradeBindingElement> upgradeBindingElements = context.BindingParameters.FindAll <StreamUpgradeBindingElement>(); if (upgradeBindingElements.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.MultipleStreamUpgradeProvidersInParameters)); } else if ((upgradeBindingElements.Count == 1) && this.SupportsUpgrade(upgradeBindingElements[0])) { _upgrade = upgradeBindingElements[0].BuildClientStreamUpgradeProvider(context); context.BindingParameters.Remove <StreamUpgradeBindingElement>(); _securityCapabilities = upgradeBindingElements[0].GetProperty <ISecurityCapabilities>(context); // flow the identity only if the channel factory supports impersonating during an async open AND // there is the binding is configured with security _flowIdentity = supportsImpersonationDuringAsyncOpen; } // We explicitly declare this type and all derived types support // async open/close. We currently must do this because the NET Native // toolchain does not recognize this type was granted Reflection degree. // Is it safe to do this only because this is an internal type and no // derived type is public or exposed in contract. SupportsAsyncOpenClose = true; }
private bool GetUpgradeAndConnectionPool(out StreamUpgradeProvider upgradeCopy, out ConnectionPool poolCopy) { if ((this.upgrade != null) || (this.connectionPool != null)) { lock (base.ThisLock) { if ((this.upgrade != null) || (this.connectionPool != null)) { upgradeCopy = this.upgrade; poolCopy = this.connectionPool; this.upgrade = null; this.connectionPool = null; return(true); } } } upgradeCopy = null; poolCopy = null; return(false); }
private bool GetUpgradeAndConnectionPool(out StreamUpgradeProvider upgradeCopy, out ConnectionPool poolCopy) { if (_upgrade != null || _connectionPool != null) { lock (ThisLock) { if (_upgrade != null || _connectionPool != null) { upgradeCopy = _upgrade; poolCopy = _connectionPool; _upgrade = null; _connectionPool = null; return(true); } } } upgradeCopy = null; poolCopy = null; return(false); }
internal ConnectionOrientedTransportChannelFactory( ConnectionOrientedTransportBindingElement bindingElement, BindingContext context, string connectionPoolGroupName, TimeSpan idleTimeout, int maxOutboundConnectionsPerEndpoint, bool supportsImpersonationDuringAsyncOpen) : base(bindingElement, context) { if (bindingElement.TransferMode == TransferMode.Buffered && bindingElement.MaxReceivedMessageSize > int.MaxValue) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ArgumentOutOfRangeException("bindingElement.MaxReceivedMessageSize", SR.MaxReceivedMessageSizeMustBeInIntegerRange)); } _connectionBufferSize = bindingElement.ConnectionBufferSize; _connectionPoolGroupName = connectionPoolGroupName; _exposeConnectionProperty = bindingElement.ExposeConnectionProperty; _idleTimeout = idleTimeout; _maxBufferSize = bindingElement.MaxBufferSize; _maxOutboundConnectionsPerEndpoint = maxOutboundConnectionsPerEndpoint; _maxOutputDelay = bindingElement.MaxOutputDelay; _transferMode = bindingElement.TransferMode; Collection <StreamUpgradeBindingElement> upgradeBindingElements = context.BindingParameters.FindAll <StreamUpgradeBindingElement>(); if (upgradeBindingElements.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.MultipleStreamUpgradeProvidersInParameters)); } else if ((upgradeBindingElements.Count == 1) && this.SupportsUpgrade(upgradeBindingElements[0])) { _upgrade = upgradeBindingElements[0].BuildClientStreamUpgradeProvider(context); context.BindingParameters.Remove <StreamUpgradeBindingElement>(); _securityCapabilities = upgradeBindingElements[0].GetProperty <ISecurityCapabilities>(context); // flow the identity only if the channel factory supports impersonating during an async open AND // there is the binding is configured with security _flowIdentity = supportsImpersonationDuringAsyncOpen; } }
public static FramingDuplexSessionChannel.ConnectionDuplexSession CreateSession(FramingDuplexSessionChannel channel, StreamUpgradeProvider upgrade) { if (upgrade is StreamSecurityUpgradeProvider) { return(new SecureConnectionDuplexSession(channel)); } return(new FramingDuplexSessionChannel.ConnectionDuplexSession(channel)); }
public IConnection CompletePreamble(TimeSpan timeout) { int num; TimeoutHelper timeoutHelper = new TimeoutHelper(timeout); if (!this.transportSettings.MessageEncoderFactory.Encoder.IsContentTypeSupported(this.decoder.ContentType)) { this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/ContentTypeInvalid", ref timeoutHelper); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("ContentTypeMismatch", new object[] { this.decoder.ContentType, this.transportSettings.MessageEncoderFactory.Encoder.ContentType }))); } StreamUpgradeAcceptor upgradeAcceptor = null; StreamUpgradeProvider upgrade = this.transportSettings.Upgrade; IStreamUpgradeChannelBindingProvider property = null; if (upgrade != null) { property = upgrade.GetProperty <IStreamUpgradeChannelBindingProvider>(); upgradeAcceptor = upgrade.CreateUpgradeAcceptor(); } IConnection connection = base.Connection; Label_00B1: if (this.size == 0) { this.offset = 0; this.size = connection.Read(this.connectionBuffer, 0, this.connectionBuffer.Length, timeoutHelper.RemainingTime()); if (this.size == 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.decoder.CreatePrematureEOFException()); } } Label_0101: num = this.decoder.Decode(this.connectionBuffer, this.offset, this.size); if (num > 0) { this.offset += num; this.size -= num; } switch (this.decoder.CurrentState) { case ServerSingletonDecoder.State.UpgradeRequest: { if (upgradeAcceptor == null) { this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/UpgradeInvalid", ref timeoutHelper); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("UpgradeRequestToNonupgradableService", new object[] { this.decoder.Upgrade }))); } if (!upgradeAcceptor.CanUpgrade(this.decoder.Upgrade)) { this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/UpgradeInvalid", ref timeoutHelper); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(System.ServiceModel.SR.GetString("UpgradeProtocolNotSupported", new object[] { this.decoder.Upgrade }))); } connection.Write(ServerSingletonEncoder.UpgradeResponseBytes, 0, ServerSingletonEncoder.UpgradeResponseBytes.Length, true, timeoutHelper.RemainingTime()); IConnection innerConnection = connection; if (this.size > 0) { innerConnection = new PreReadConnection(innerConnection, this.connectionBuffer, this.offset, this.size); } try { connection = InitialServerConnectionReader.UpgradeConnection(innerConnection, upgradeAcceptor, this.transportSettings); this.connectionBuffer = connection.AsyncReadBuffer; if ((property != null) && property.IsChannelBindingSupportEnabled) { this.channelBindingToken = property.GetChannelBinding(upgradeAcceptor, ChannelBindingKind.Endpoint); } goto Label_02C0; } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.WriteAuditFailure(upgradeAcceptor as StreamSecurityUpgradeAcceptor, exception); throw; } break; } case ServerSingletonDecoder.State.Start: break; default: goto Label_02C0; } this.SetupSecurityIfNecessary(upgradeAcceptor); connection.Write(ServerSessionEncoder.AckResponseBytes, 0, ServerSessionEncoder.AckResponseBytes.Length, true, timeoutHelper.RemainingTime()); return(connection); Label_02C0: if (this.size != 0) { goto Label_0101; } goto Label_00B1; }
public ConnectionOrientedTransportReplyChannelAcceptor(ConnectionOrientedTransportChannelListener listener) : base(listener) { this.upgrade = listener.GetUpgrade(); }