public override bool GetParameters(TextBuffer textBuffer) { switch (_state) { case State.SendAlgorithm: textBuffer.Add("CHAP_A", "5"); _state = State.ReceiveChallenge; return false; case State.SendResponse: textBuffer.Add("CHAP_N", _name); textBuffer.Add("CHAP_R", CalcResponse()); _state = State.Finished; return true; default: throw new InvalidOperationException("Unknown authentication state: " + _state); } }
public override void SetParameters(TextBuffer textBuffer) { switch (_state) { case State.ReceiveChallenge: _algorithm = int.Parse(textBuffer["CHAP_A"], CultureInfo.InvariantCulture); _identifier = byte.Parse(textBuffer["CHAP_I"], CultureInfo.InvariantCulture); _challenge = ParseByteString(textBuffer["CHAP_C"]); _state = State.SendResponse; if (_algorithm != 0x5) { throw new LoginException("Unexpected CHAP authentication algorithm: " + _algorithm); } return; default: throw new InvalidOperationException("Unknown authentication state: " + _state); } }