Пример #1
0
        private void SendServerMechanisms()
        {
            List <AmqpSymbol> amqpSymbols = new List <AmqpSymbol>();

            foreach (string mechanism in this.provider.Mechanisms)
            {
                amqpSymbols.Add(new AmqpSymbol(mechanism));
            }
            SaslMechanisms saslMechanism = new SaslMechanisms()
            {
                SaslServerMechanisms = new Multiple <AmqpSymbol>(amqpSymbols)
            };

            this.state = SaslNegotiator.SaslState.WaitingForInit;
            this.WriteFrame(saslMechanism, true);
        }
Пример #2
0
        void SendServerMechanisms()
        {
            List <AmqpSymbol> mechanisms = new List <AmqpSymbol>();

            foreach (string mechanism in this.provider.Mechanisms)
            {
                mechanisms.Add(new AmqpSymbol(mechanism));
            }

            SaslMechanisms salsMechanisms = new SaslMechanisms();

            salsMechanisms.SaslServerMechanisms = new Multiple <AmqpSymbol>(mechanisms);
            this.state = SaslState.WaitingForInit;
            this.WriteFrame(salsMechanisms, true);
            Utils.Trace(TraceLevel.Verbose, "{0}: sent server mechanisms", this.transport);
        }
Пример #3
0
        private void OnSaslServerMechanisms(SaslMechanisms mechanisms)
        {
            if (this.state != SaslNegotiator.SaslState.WaitingForServerMechanisms)
            {
                throw new AmqpException(AmqpError.IllegalState, SRAmqp.AmqpIllegalOperationState("R:SASL-MECH", this.state));
            }
            string str = null;

            using (IEnumerator <string> enumerator = this.provider.Mechanisms.GetEnumerator())
            {
                do
                {
                    if (!enumerator.MoveNext())
                    {
                        break;
                    }
                    string current = enumerator.Current;
                    if (!mechanisms.SaslServerMechanisms.Contains(new AmqpSymbol(current)))
                    {
                        continue;
                    }
                    str = current;
                    break;
                }while (str == null);
            }
            if (str == null)
            {
                throw new AmqpException(AmqpError.NotFound, SRAmqp.AmqpNotSupportMechanism);
            }
            this.state       = SaslNegotiator.SaslState.Negotiating;
            this.saslHandler = this.provider.GetHandler(str, true);
            SaslInit saslInit = new SaslInit()
            {
                Mechanism = str
            };

            this.saslHandler.Start(this, saslInit, true);
        }
Пример #4
0
        /// <summary>
        /// Client receives the announced server mechanisms.
        /// </summary>
        void OnSaslServerMechanisms(SaslMechanisms mechanisms)
        {
            if (this.state != SaslState.WaitingForServerMechanisms)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState("R:SASL-MECH", this.state));
            }

            Utils.Trace(TraceLevel.Verbose, "{0}: on sasl server mechanisms", this.transport);
            string mechanismToUse = null;

            foreach (string mechanism in this.provider.Mechanisms)
            {
                if (mechanisms.SaslServerMechanisms.Contains(new AmqpSymbol(mechanism)))
                {
                    mechanismToUse = mechanism;
                    break;
                }

                if (mechanismToUse != null)
                {
                    break;
                }
            }

            if (mechanismToUse == null)
            {
                throw new AmqpException(AmqpError.NotFound, SRClient.AmqpNotSupportMechanism);
            }

            this.state       = SaslState.Negotiating;
            this.saslHandler = this.provider.GetHandler(mechanismToUse, false);
            SaslInit init = new SaslInit();

            init.Mechanism = mechanismToUse;
            this.saslHandler.Start(this, init, true);
        }
Пример #5
0
        /// <summary>
        /// Client receives the announced server mechanisms.
        /// </summary>
        void OnSaslServerMechanisms(SaslMechanisms mechanisms)
        {
            if (this.state != SaslState.WaitingForServerMechanisms)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState("R:SASL-MECH", this.state));
            }

            Utils.Trace(TraceLevel.Verbose, "{0}: on sasl server mechanisms", this.transport);
            string mechanismToUse = null;
            foreach (string mechanism in this.provider.Mechanisms)
            {
                if (mechanisms.SaslServerMechanisms.Contains(new AmqpSymbol(mechanism)))
                {
                    mechanismToUse = mechanism;
                    break;
                }

                if (mechanismToUse != null)
                {
                    break;
                }
            }

            if (mechanismToUse == null)
            {
                throw new AmqpException(AmqpError.NotFound, SRClient.AmqpNotSupportMechanism);
            }

            this.state = SaslState.Negotiating;
            this.saslHandler = this.provider.GetHandler(mechanismToUse, false);
            SaslInit init = new SaslInit();
            init.Mechanism = mechanismToUse;
            this.saslHandler.Start(this, init, true);
        }
Пример #6
0
        void SendServerMechanisms()
        {
            List<AmqpSymbol> mechanisms = new List<AmqpSymbol>();
            foreach (string mechanism in this.provider.Mechanisms)
            {
                mechanisms.Add(new AmqpSymbol(mechanism));
            }

            SaslMechanisms salsMechanisms = new SaslMechanisms();
            salsMechanisms.SaslServerMechanisms = new Multiple<AmqpSymbol>(mechanisms);
            this.state = SaslState.WaitingForInit;
            this.WriteFrame(salsMechanisms, true);
            Utils.Trace(TraceLevel.Verbose, "{0}: sent server mechanisms", this.transport);
        }