상속: TransportProvider
예제 #1
0
 public SaslNegotiator(SaslTransport transport, SaslTransportProvider provider, bool isInitiator)
 {
     this.transport   = transport;
     this.provider    = provider;
     this.isInitiator = isInitiator;
     this.state       = SaslState.Start;
 }
예제 #2
0
 public SaslNegotiator(SaslTransport transport, SaslTransportProvider provider, bool isInitiator)
 {
     this.transport = transport;
     this.provider = provider;
     this.isInitiator = isInitiator;
     this.state = SaslState.Start;
 }
예제 #3
0
 public SaslTransport(TransportBase transport, SaslTransportProvider provider, bool isInitiator)
     : base("sasl", transport.Identifier)
 {
     this.innerTransport = transport;
     this.negotiator     = new SaslNegotiator(this, provider, isInitiator);
 }
예제 #4
0
        public TestAmqpBroker(IList<string> endpoints, string userInfo, string sslValue, string[] queues)
        {
            this.containerId = "TestAmqpBroker-P" + Process.GetCurrentProcess().Id;
            this.maxFrameSize = 64 * 1024;
            this.txnManager = new TxnManager();
            this.connections = new Dictionary<SequenceNumber, AmqpConnection>();
            this.queues = new Dictionary<string, TestQueue>();
            if (queues != null)
            {
                foreach (string q in queues)
                {
                    this.queues.Add(q, new TestQueue(this));
                }
            }
            else
            {
                this.implicitQueue = true;
            }

            // create and initialize AmqpSettings
            AmqpSettings settings = new AmqpSettings();
            X509Certificate2 certificate = sslValue == null ? null : GetCertificate(sslValue);
            settings.RuntimeProvider = this;

            SaslHandler saslHandler;
            if (userInfo != null)
            {
                string[] creds = userInfo.Split(':');
                string usernanme = Uri.UnescapeDataString(creds[0]);
                string password = creds.Length == 1 ? string.Empty : Uri.UnescapeDataString(creds[1]);
                saslHandler = new SaslPlainHandler(new TestPlainAuthenticator(userInfo, password));
            }
            else
            {
                saslHandler = new SaslAnonymousHandler();
            }

            SaslTransportProvider saslProvider = new SaslTransportProvider();
            saslProvider.AddHandler(saslHandler);
            saslProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(saslProvider);

            AmqpTransportProvider amqpProvider = new AmqpTransportProvider();
            amqpProvider.Versions.Add(new AmqpVersion(1, 0, 0));
            settings.TransportProviders.Add(amqpProvider);

            // create and initialize transport listeners
            TransportListener[] listeners = new TransportListener[endpoints.Count];
            for (int i = 0; i < endpoints.Count; i++)
            {
                Uri addressUri = new Uri(endpoints[i]);

                TcpTransportSettings tcpSettings = new TcpTransportSettings() { Host = addressUri.Host, Port = addressUri.Port };
                if (addressUri.Scheme.Equals(AmqpConstants.SchemeAmqps, StringComparison.OrdinalIgnoreCase))
                {
                    if (certificate == null)
                    {
                        throw new InvalidOperationException("/cert option was not set when amqps address is specified.");
                    }

                    TlsTransportSettings tlsSettings = new TlsTransportSettings(tcpSettings) { Certificate = certificate, IsInitiator = false };
                    listeners[i] = tlsSettings.CreateListener();
                }
                else
                {
                    listeners[i] = tcpSettings.CreateListener();
                }
            }

            this.transportListener = new AmqpTransportListener(listeners, settings);
            this.settings = settings;
        }