public override T GetProperty <T>() { if (typeof(T) == typeof(ISecurityCapabilities)) { return((T)(object)_securityCapabilities); } T result = base.GetProperty <T>(); if (result == null && _upgrade != null) { result = _upgrade.GetProperty <T>(); } return(result); }
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(); } }
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; }