/// <summary> /// Implements memcached's SASL authenticate sequence (see the protocol docs for more details.) /// </summary> /// <param name="socket"></param> /// <returns></returns> bool Authenticate(PooledSocket socket) { SaslStep step = new SaslStart(this._authenticationProvider); socket.Send(step.GetBuffer()); while (!step.ReadResponse(socket).Success) { // challenge-response authentication if (step.StatusCode == 0x21) { step = new SaslContinue(this._authenticationProvider, step.Data); socket.Send(step.GetBuffer()); } // invalid credentials or other error else { this._logger.LogWarning("Authentication failed, return code: 0x{0:x}", step.StatusCode); return(false); } } return(true); }