Class: HrrRbSsh::Authentication::Method::KeyboardInteractive
- Inherits:
-
HrrRbSsh::Authentication::Method
- Object
- HrrRbSsh::Authentication::Method
- HrrRbSsh::Authentication::Method::KeyboardInteractive
- Defined in:
- lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/context.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_request.rb,
lib/hrr_rb_ssh/authentication/method/keyboard_interactive/info_response.rb
Defined Under Namespace
Classes: Context, InfoRequest, InfoResponse
Constant Summary collapse
- NAME =
'keyboard-interactive'- PREFERENCE =
30
Instance Method Summary collapse
- #authenticate(userauth_request_message) ⇒ Object
-
#initialize(transport, options, variables, authentication_methods) ⇒ KeyboardInteractive
constructor
A new instance of KeyboardInteractive.
- #request_authentication(username, service_name) ⇒ Object
Methods included from SubclassWithPreferenceListable
#[], #inherited, #list_preferred, #list_supported
Constructor Details
#initialize(transport, options, variables, authentication_methods) ⇒ KeyboardInteractive
Returns a new instance of KeyboardInteractive.
13 14 15 16 17 18 19 20 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 13 def initialize transport, , variables, authentication_methods @logger = Logger.new(self.class.name) @transport = transport = @authenticator = .fetch( 'authentication_keyboard_interactive_authenticator', Authenticator.new { false } ) @variables = variables @authentication_methods = authentication_methods end |
Instance Method Details
#authenticate(userauth_request_message) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 22 def authenticate @logger.info { "authenticate" } @logger.debug { "userauth request: " + .inspect } username = [:'user name'] submethods = [:'submethods'] context = Context.new(@transport, username, submethods, @variables, @authentication_methods) @authenticator.authenticate context end |
#request_authentication(username, service_name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hrr_rb_ssh/authentication/method/keyboard_interactive.rb', line 31 def request_authentication username, service_name = { :'message number' => Message::SSH_MSG_USERAUTH_REQUEST::VALUE, :"user name" => username, :"service name" => service_name, :"method name" => NAME, :"language tag" => "", :'submethods' => "", } payload = Message::SSH_MSG_USERAUTH_REQUEST.encode @transport.send payload payload = @transport.receive case payload[0,1].unpack("C")[0] when Message::SSH_MSG_USERAUTH_INFO_REQUEST::VALUE = Message::SSH_MSG_USERAUTH_INFO_REQUEST.decode payload num_responses = ['client_authentication_keyboard_interactive'].size = { :'message number' => Message::SSH_MSG_USERAUTH_INFO_RESPONSE::VALUE, :'num-responses' => num_responses, } = ['client_authentication_keyboard_interactive'].map.with_index{ |response, i| {:"response[#{i+1}]" => response} }.inject(Hash.new){ |a, b| a.merge(b) } .update() payload = Message::SSH_MSG_USERAUTH_INFO_RESPONSE.encode @transport.send payload @transport.receive else payload end end |