| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Text; |
| | | 4 | | using Renci.SshNet.Common; |
| | | 5 | | |
| | | 6 | | namespace Renci.SshNet.Messages.Authentication |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents SSH_MSG_USERAUTH_INFO_REQUEST message. |
| | | 10 | | /// </summary> |
| | | 11 | | [Message("SSH_MSG_USERAUTH_INFO_REQUEST", 60)] |
| | | 12 | | internal sealed class InformationRequestMessage : Message |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Gets information request name. |
| | | 16 | | /// </summary> |
| | 9 | 17 | | public string Name { get; private set; } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Gets information request instruction. |
| | | 21 | | /// </summary> |
| | 18 | 22 | | public string Instruction { get; private set; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets information request language. |
| | | 26 | | /// </summary> |
| | 18 | 27 | | public string Language { get; private set; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets information request prompts. |
| | | 31 | | /// </summary> |
| | 18 | 32 | | public IEnumerable<AuthenticationPrompt> Prompts { get; private set; } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Called when type specific data need to be loaded. |
| | | 36 | | /// </summary> |
| | | 37 | | protected override void LoadData() |
| | 9 | 38 | | { |
| | 9 | 39 | | Name = ReadString(Encoding.UTF8); |
| | 9 | 40 | | Instruction = ReadString(Encoding.UTF8); |
| | | 41 | | |
| | | 42 | | // language tag as defined in rfc3066: |
| | | 43 | | // Language tags may always be presented using the characters A-Z, a-z, 0 - 9 and HYPHEN-MINUS |
| | 9 | 44 | | Language = ReadString(Ascii); |
| | | 45 | | |
| | 9 | 46 | | var numOfPrompts = ReadUInt32(); |
| | 9 | 47 | | var prompts = new List<AuthenticationPrompt>(); |
| | | 48 | | |
| | 30 | 49 | | for (var i = 0; i < numOfPrompts; i++) |
| | 6 | 50 | | { |
| | 6 | 51 | | var prompt = ReadString(Encoding.UTF8); |
| | 6 | 52 | | var echo = ReadBoolean(); |
| | 6 | 53 | | prompts.Add(new AuthenticationPrompt(i, echo, prompt)); |
| | 6 | 54 | | } |
| | | 55 | | |
| | 9 | 56 | | Prompts = prompts; |
| | 9 | 57 | | } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Called when type specific data need to be saved. |
| | | 61 | | /// </summary> |
| | | 62 | | protected override void SaveData() |
| | 0 | 63 | | { |
| | 0 | 64 | | throw new NotImplementedException(); |
| | | 65 | | } |
| | | 66 | | |
| | | 67 | | internal override void Process(Session session) |
| | 9 | 68 | | { |
| | 9 | 69 | | session.OnUserAuthenticationInformationRequestReceived(this); |
| | 9 | 70 | | } |
| | | 71 | | } |
| | | 72 | | } |