Пример #1
0
        public void CompleteNegotiation(SaslCode code, Exception exception)
        {
            if (!this.transport.IsInitiator)
            {
                SaslOutcome outcome = new SaslOutcome();
                outcome.OutcomeCode = code;
                if (code == SaslCode.Ok)
                {
                    outcome.AdditionalData = new ArraySegment <byte>(Encoding.UTF8.GetBytes(welcome));
                }

                Utils.Trace(TraceLevel.Info, "{0}: sending sasl outcome {1}", this.transport, code);
                this.WriteFrame(outcome, false);
            }

            this.state = SaslState.End;
            if (exception != null)
            {
                this.transport.OnNegotiationFail(exception);
            }
            else
            {
                this.transport.OnNegotiationSucceed(this.saslHandler.Principal);
            }
        }
Пример #2
0
        private void OnSaslOutcome(SaslOutcome outcome)
        {
            Exception unauthorizedAccessException = null;

            if (outcome.OutcomeCode.Value != SaslCode.Ok)
            {
                SaslCode?outcomeCode = outcome.OutcomeCode;
                unauthorizedAccessException = new UnauthorizedAccessException(outcomeCode.Value.ToString());
            }
            this.CompleteNegotiation(outcome.OutcomeCode.Value, unauthorizedAccessException);
        }
Пример #3
0
 /// <summary>
 /// Client receives the sasl outcome from the server.
 /// </summary>
 void OnSaslOutcome(SaslOutcome outcome)
 {
     Utils.Trace(TraceLevel.Verbose, "{0}: on sasl outcome. code: {1}", this.transport, outcome.OutcomeCode.Value);
     this.state = SaslState.End;
     if (outcome.OutcomeCode.Value == SaslCode.Ok)
     {
         this.transport.OnNegotiationSucceed(null);
     }
     else
     {
         this.transport.OnNegotiationFail(new UnauthorizedAccessException(outcome.OutcomeCode.Value.ToString()));
     }
 }
Пример #4
0
        public void CompleteNegotiation(SaslCode code, Exception exception)
        {
            this.state             = SaslNegotiator.SaslState.End;
            this.completeException = exception;
            if (this.isInitiator)
            {
                this.CompleteTransport();
                return;
            }
            SaslOutcome saslOutcome = new SaslOutcome()
            {
                OutcomeCode = new SaslCode?(code)
            };

            if (code == SaslCode.Ok)
            {
                saslOutcome.AdditionalData = new ArraySegment <byte>(System.Text.Encoding.UTF8.GetBytes(SaslNegotiator.welcome));
            }
            this.WriteFrame(saslOutcome, false);
        }
Пример #5
0
        public void CompleteNegotiation(SaslCode code, Exception exception)
        {
            if (!this.transport.IsInitiator)
            {
                SaslOutcome outcome = new SaslOutcome();
                outcome.OutcomeCode = code;
                if (code == SaslCode.Ok)
                {
                    outcome.AdditionalData = new ArraySegment<byte>(Encoding.UTF8.GetBytes(welcome));
                }

                Utils.Trace(TraceLevel.Info, "{0}: sending sasl outcome {1}", this.transport, code);
                this.WriteFrame(outcome, false);
            }

            this.state = SaslState.End;
            if (exception != null)
            {
                this.transport.OnNegotiationFail(exception);
            }
            else
            {
                this.transport.OnNegotiationSucceed(this.saslHandler.Principal);
            }
        }
Пример #6
0
 /// <summary>
 /// Client receives the sasl outcome from the server.
 /// </summary>
 void OnSaslOutcome(SaslOutcome outcome)
 {
     Utils.Trace(TraceLevel.Verbose, "{0}: on sasl outcome. code: {1}", this.transport, outcome.OutcomeCode.Value);
     this.state = SaslState.End;
     if (outcome.OutcomeCode.Value == SaslCode.Ok)
     {
         this.transport.OnNegotiationSucceed(null);
     }
     else
     {
         this.transport.OnNegotiationFail(new UnauthorizedAccessException(outcome.OutcomeCode.Value.ToString()));
     }
 }