Class: HrrRbSsh::Authentication::Method::Password
- Inherits:
-
HrrRbSsh::Authentication::Method
- Object
- HrrRbSsh::Authentication::Method
- HrrRbSsh::Authentication::Method::Password
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_ssh/authentication/method/password.rb,
lib/hrr_rb_ssh/authentication/method/password/context.rb
Defined Under Namespace
Classes: Context
Constant Summary collapse
- NAME =
'password'
- PREFERENCE =
10
Instance Attribute Summary
Attributes included from Loggable
Instance Method Summary collapse
- #authenticate(userauth_request_message) ⇒ Object
-
#initialize(transport, options, variables, authentication_methods, logger: nil) ⇒ Password
constructor
A new instance of Password.
- #request_authentication(username, service_name) ⇒ Object
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Methods included from SubclassWithPreferenceListable
#[], #inherited, #list_preferred, #list_supported
Constructor Details
#initialize(transport, options, variables, authentication_methods, logger: nil) ⇒ Password
Returns a new instance of Password.
15 16 17 18 19 20 21 22 |
# File 'lib/hrr_rb_ssh/authentication/method/password.rb', line 15 def initialize transport, , variables, authentication_methods, logger: nil self.logger = logger @transport = transport @authenticator = .fetch( 'authentication_password_authenticator', Authenticator.new{ false } ) @options = @variables = variables @authentication_methods = authentication_methods end |
Instance Method Details
#authenticate(userauth_request_message) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/hrr_rb_ssh/authentication/method/password.rb', line 24 def authenticate log_info { "authenticate" } log_debug { "userauth request: " + .inspect } username = [:'user name'] password = [:'plaintext password'] context = Context.new(username, password, @variables, @authentication_methods, logger: logger) @authenticator.authenticate context end |
#request_authentication(username, service_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hrr_rb_ssh/authentication/method/password.rb', line 33 def request_authentication username, service_name password = @options['client_authentication_password'] = { :'message number' => Message::SSH_MSG_USERAUTH_REQUEST::VALUE, :"user name" => username, :"service name" => service_name, :"method name" => NAME, :"FALSE" => false, :"plaintext password" => password, } payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode @transport.send payload payload = @transport.receive end |