Example #1
0
        /// <summary>
        /// Server receives the client init that may contain the initial response message.
        /// </summary>
        void OnSaslInit(SaslInit init)
        {
            if (this.state != SaslState.WaitingForInit)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState("R:SASL-INIT", this.state));
            }

            Utils.Trace(TraceLevel.Verbose, "{0}: on sasl init. mechanism: {1}", this.transport, init.Mechanism.Value);
            this.state       = SaslState.Negotiating;
            this.saslHandler = this.provider.GetHandler(init.Mechanism.Value, true);
            this.saslHandler.Start(this, init, false);
        }
Example #2
0
        private void OnSaslInit(SaslInit init)
        {
            if (this.state != SaslNegotiator.SaslState.WaitingForInit)
            {
                throw new AmqpException(AmqpError.IllegalState, SRAmqp.AmqpIllegalOperationState("R:SASL-INIT", this.state));
            }
            this.state = SaslNegotiator.SaslState.Negotiating;
            SaslTransportProvider saslTransportProvider = this.provider;
            AmqpSymbol            mechanism             = init.Mechanism;

            this.saslHandler = saslTransportProvider.GetHandler(mechanism.Value, true);
            this.saslHandler.Start(this, init, false);
        }
Example #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);
        }
Example #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);
        }
 public void AddHandler(SaslHandler handler)
 {
     Utils.Trace(TraceLevel.Info, "{0}: Add a SASL handler: {1}", this, handler);
     this.handlers.Add(handler.Mechanism, handler);
 }
Example #6
0
        /// <summary>
        /// Server receives the client init that may contain the initial response message.
        /// </summary>
        void OnSaslInit(SaslInit init)
        {
            if (this.state != SaslState.WaitingForInit)
            {
                throw new AmqpException(AmqpError.IllegalState, SRClient.AmqpIllegalOperationState("R:SASL-INIT", this.state));
            }

            Utils.Trace(TraceLevel.Verbose, "{0}: on sasl init. mechanism: {1}", this.transport, init.Mechanism.Value);
            this.state = SaslState.Negotiating;
            this.saslHandler = this.provider.GetHandler(init.Mechanism.Value, true);
            this.saslHandler.Start(this, init, false);
        }
Example #7
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);
        }
 public void AddHandler(SaslHandler handler)
 {
     Utils.Trace(TraceLevel.Info, "{0}: Add a SASL handler: {1}", this, handler);
     this.handlers.Add(handler.Mechanism, handler);
 }
 public void AddHandler(SaslHandler handler)
 {
     MessagingClientEtwProvider.TraceClient <SaslTransportProvider, SaslHandler>((SaslTransportProvider source, SaslHandler detail) => MessagingClientEtwProvider.Provider.EventWriteAmqpLogOperation(source, TraceOperation.Add, detail), this, handler);
     this.handlers.Add(handler.Mechanism, handler);
 }