using System;
using System.Collections.Generic;
using System.Text;
using Renci.SshNet.Common;
namespace Renci.SshNet.Messages.Authentication
{
///
/// Represents SSH_MSG_USERAUTH_INFO_REQUEST message.
///
[Message("SSH_MSG_USERAUTH_INFO_REQUEST", 60)]
internal class InformationRequestMessage : Message
{
///
/// Gets information request name.
///
public string Name { get; private set; }
///
/// Gets information request instruction.
///
public string Instruction { get; private set; }
///
/// Gets information request language.
///
public string Language { get; private set; }
///
/// Gets information request prompts.
///
public IEnumerable Prompts { get; private set; }
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
Name = ReadString(Encoding.UTF8);
Instruction = ReadString(Encoding.UTF8);
// language tag as defined in rfc3066:
// Language tags may always be presented using the characters A-Z, a-z, 0 - 9 and HYPHEN-MINUS
Language = ReadString(Ascii);
var numOfPrompts = ReadUInt32();
var prompts = new List();
for (var i = 0; i < numOfPrompts; i++)
{
var prompt = ReadString(Encoding.UTF8);
var echo = ReadBoolean();
prompts.Add(new AuthenticationPrompt(i, echo, prompt));
}
Prompts = prompts;
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
throw new NotImplementedException();
}
internal override void Process(Session session)
{
session.OnUserAuthenticationInformationRequestReceived(this);
}
}
}