/// <inheritdoc /> public PamResponse <string> PromptEchoOn(string text) { Console.Out.Write(text); Console.Out.Flush(); try { var input = Console.In.ReadLine() ?? string.Empty; return(PamResponse <string> .Success(input)); } catch (Exception ex) { _logger?.LogError(ex, ex.Message); return(PamResponse <string> .Error(PamStatus.PAM_AUTH_ERR)); } }
/// <inheritdoc /> public PamResponse <string> PromptEchoOff(string text) { Console.Out.Write(text); Console.Out.Flush(); var conInput = new StringBuilder(); var finished = false; while (!finished) { var key = Console.ReadKey(true); switch (key.Key) { case ConsoleKey.Backspace: if (conInput.Length != 0) { conInput.Remove(conInput.Length - 1, 1); } break; case ConsoleKey.Escape: conInput.Clear(); break; case ConsoleKey.Enter: case ConsoleKey.Execute: finished = true; break; default: if (key.KeyChar >= 32) { conInput.Append(key.KeyChar); } break; } } Console.Out.WriteLine(); var input = conInput.ToString(); return(PamResponse <string> .Success(input)); }
/// <inheritdoc /> public PamResponse <string> PromptEchoOn(string text) { return(PamResponse <string> .Success(Credential.UserName)); }
/// <inheritdoc /> public PamResponse <string> PromptEchoOff(string text) { return(PamResponse <string> .Success(Credential.Password)); }