Class: HrrRbSsh::Authentication::Method::KeyboardInteractive::InfoRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, instruction, language_tag, prompts) ⇒ InfoRequest

Returns a new instance of InfoRequest.



12
13
14
15
16
17
18
19
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb', line 12

def initialize name, instruction, language_tag, prompts
  @name         = name
  @instruction  = instruction
  @language_tag = language_tag
  @prompts      = prompts

  @logger = Logger.new self.class.name
end

Instance Method Details

#to_messageObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb', line 21

def to_message
  message = {
    :'message number' => Message::SSH_MSG_USERAUTH_INFO_REQUEST::VALUE,
    :'name'           => @name,
    :'instruction'    => @instruction,
    :'language tag'   => @language_tag,
    :'num-prompts'    => @prompts.size,
  }
  message_prompts = @prompts.map.with_index{ |(prompt, echo), i|
    [
      [:"prompt[#{i+1}]", prompt],
      [:"echo[#{i+1}]",   echo],
    ].to_h
  }.inject(Hash.new){ |a, b| a.merge(b) }
  message.merge(message_prompts)
end

#to_payloadObject



38
39
40
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb', line 38

def to_payload
  Message::SSH_MSG_USERAUTH_INFO_REQUEST.encode self.to_message
end