protected override TransportBase OnCreateTransport(TransportBase innerTransport, bool isInitiator) { if (innerTransport.GetType() == typeof(SaslTransport)) { throw new InvalidOperationException(AmqpResources.GetString(AmqpResources.AmqpTransportUpgradeNotAllowed, innerTransport.GetType().Name, typeof(SaslTransport).Name)); } return new SaslTransport(innerTransport, this, isInitiator); }
public TlsTransport(TransportBase innerTransport, TlsTransportSettings tlsSettings) : base("tls", innerTransport.Identifier) { Fx.Assert((tlsSettings.IsInitiator && tlsSettings.TargetHost != null) || (!tlsSettings.IsInitiator && tlsSettings.Certificate != null), tlsSettings.IsInitiator ? "Must have a target host for the client." : "Must have a certificate for the server."); this.innerTransport = innerTransport; this.tlsSettings = tlsSettings; this.sslStream = tlsSettings.CertificateValidationCallback == null ? new CustomSslStream(new TransportStream(this.innerTransport), false, tlsSettings.IsInitiator) : new CustomSslStream(new TransportStream(this.innerTransport), false, tlsSettings.CertificateValidationCallback, tlsSettings.IsInitiator); }
public AsyncIO(IIoHandler parent, int maxFrameSize, int writeQueueFullLimit, int writeQueueEmptyLimit, TransportBase transport, bool isInitiator) : base("async-io", transport.Identifier) { Fx.Assert(transport != null, "transport required"); this.ioHandler = parent; this.transport = transport; this.writer = this.transport.RequiresCompleteFrames ? new AsyncFrameWriter(this.transport, writeQueueFullLimit, writeQueueEmptyLimit, parent) : new AsyncWriter(this.transport, writeQueueFullLimit, writeQueueEmptyLimit, parent); this.reader = new AsyncReader(this, maxFrameSize, isInitiator); }
protected AmqpConnectionBase(string type, TransportBase transport, AmqpConnectionSettings settings, bool isInitiator) : base(type, transport.Identifier) { if (settings == null) { throw new ArgumentNullException("settings"); } Fx.Assert(transport != null, "transport must not be null."); this.settings = settings; this.asyncIO = new AsyncIO(this, (int)this.settings.MaxFrameSize(), this.settings.WriteBufferFullLimit, this.settings.WriteBufferEmptyLimit, transport, isInitiator); }
protected override TransportBase OnCreateTransport(TransportBase innerTransport, bool isInitiator) { #if !PCL if (innerTransport.GetType() != typeof(TcpTransport)) { throw new InvalidOperationException(AmqpResources.GetString(AmqpResources.AmqpTransportUpgradeNotAllowed, innerTransport.GetType().Name, typeof(TlsTransport).Name)); } return new TlsTransport(innerTransport, this.tlsSettings); #else throw new NotImplementedException(Microsoft.Azure.Amqp.PCL.Resources.ReferenceAssemblyInvalidUse); #endif }
public TlsTransport(TransportBase innerTransport, TlsTransportSettings tlsSettings) : base("tls", innerTransport.Identifier) { this.innerTransport = innerTransport; this.tlsSettings = tlsSettings; var tcpTransport = innerTransport as TcpTransport; if (tcpTransport != null) { this.socket = tcpTransport.Socket; } else { throw new NotSupportedException("Only TCP transport is supported"); } }
public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : base((isInitiator ? "out" : "in") + "-connection", transport, connectionSettings, isInitiator) { if (amqpSettings == null) { throw new ArgumentNullException("amqpSettings"); } this.initialHeader = protocolHeader; this.isInitiator = isInitiator; this.amqpSettings = amqpSettings; this.sessionsByLocalHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax ?? AmqpConstants.DefaultMaxConcurrentChannels - 1); this.sessionsByRemoteHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax ?? AmqpConstants.DefaultMaxConcurrentChannels - 1); this.SessionFactory = this; this.heartBeat = HeartBeat.None; }
public TransportBase CreateTransport(TransportBase innerTransport, bool isInitiator) { return(this.OnCreateTransport(innerTransport, isInitiator)); }
/// <summary> /// Creates a TLS transport from the inner transport. /// </summary> /// <param name="innerTransport">The inner transport.</param> /// <param name="tlsTransportSettings">The TLS transport settings.</param> /// <returns></returns> protected virtual TlsTransport OnCreateTransport(TransportBase innerTransport, TlsTransportSettings tlsTransportSettings) { return(new TlsTransport(innerTransport, tlsTransportSettings)); }
protected override TransportBase OnCreateTransport(TransportBase innerTransport, bool isInitiator) { return(new TlsTransport(innerTransport, this.tlsSettings)); }
public TransportStream(TransportBase transport) { this.transport = transport; }
void OnProtocolHeader(ByteBuffer buffer) { ProtocolHeader header = new ProtocolHeader(); header.Decode(buffer); AmqpTrace.Provider.AmqpLogOperationInformational(this, TraceOperation.Receive, header); // Protocol id negotiation TransportProvider provider = null; if (!this.parent.settings.TryGetTransportProvider(header, out provider)) { Fx.Assert(provider != null, "At least on provider should be configured."); this.WriteReplyHeader(new ProtocolHeader(provider.ProtocolId, provider.DefaultVersion), true); return; } // Protocol version negotiation AmqpVersion version; if (!provider.TryGetVersion(header.Version, out version)) { this.WriteReplyHeader(new ProtocolHeader(provider.ProtocolId, version), true); return; } TransportBase newTransport = null; try { newTransport = provider.CreateTransport(this.args.Transport, false); } catch (InvalidOperationException ioe) { // treat this the same as protocol ID/version failure // which are all client config issues AmqpTrace.Provider.AmqpLogError(this, "CreateTransport", ioe.Message); this.WriteReplyHeader(ProtocolHeader.Amqp100, true); return; } if (object.ReferenceEquals(newTransport, this.args.Transport)) { if ((this.parent.settings.RequireSecureTransport && !newTransport.IsSecure) || (!this.parent.settings.AllowAnonymousConnection && !newTransport.IsAuthenticated)) { AmqpTrace.Provider.AmqpInsecureTransport(this.parent, newTransport, newTransport.IsSecure, newTransport.IsAuthenticated); this.WriteReplyHeader(this.parent.settings.GetDefaultHeader(), true); } else { this.args.UserToken = header; this.parent.OnHandleTransportComplete(this.args); } } else { #if DEBUG header.Trace(false); #endif AmqpTrace.Provider.AmqpUpgradeTransport(this, args.Transport, newTransport); this.args.Transport = newTransport; this.WriteReplyHeader(header, false); } }
public AsyncBufferReader(TransportBase transport) { this.transport = transport; }
public FrameBufferReader(IIoHandler parent, TransportBase transport, int maxFrameSize) { this.parent = parent; this.transport = transport; this.maxFrameSize = maxFrameSize; this.sizeBuffer = new byte[FixedWidth.UInt]; }
public AsyncWriter(TransportBase transport, int writeQueueFullLimit, int writeQueueEmptyLimit, IIoHandler parent) { this.transport = transport; this.writeQueueFullLimit = writeQueueFullLimit; this.writeQueueEmptyLimit = writeQueueEmptyLimit; this.parent = parent; this.bufferQueue = new Queue<ByteBuffer>(); this.writeAsyncEventArgs = new TransportAsyncCallbackArgs(); this.writeAsyncEventArgs.CompletedCallback = writeCompleteCallback; }
public AsyncFrameWriter(TransportBase transport, int writeQueueFullLimit, int writeQueueEmptyLimit, IIoHandler parent) : base(transport, writeQueueFullLimit, writeQueueEmptyLimit, parent) { }
protected abstract TransportBase OnCreateTransport(TransportBase innerTransport, bool isInitiator);
public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : this(transport, protocolHeader, true, amqpSettings, connectionSettings) { }
public AmqpConnection(TransportBase transport, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : this(transport, amqpSettings.GetDefaultHeader(), true, amqpSettings, connectionSettings) { }
public AsyncBufferWriter(TransportBase transport) { this.transport = transport; }
public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) { return new AmqpConnection(transport, protocolHeader, false, amqpSettings, connectionSettings); }