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); } }
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); }
/// <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())); } }
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); }
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); } }