Class: HrrRbSsh::Authentication::Method::None

Inherits:
HrrRbSsh::Authentication::Method show all
Includes:
Loggable
Defined in:
lib/hrr_rb_ssh/authentication/method/none.rb,
lib/hrr_rb_ssh/authentication/method/none/context.rb

Defined Under Namespace

Classes: Context

Constant Summary collapse

NAME =
'none'
PREFERENCE =
0

Instance Attribute Summary

Attributes included from Loggable

#log_key, #logger

Instance Method Summary collapse

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) ⇒ None

Returns a new instance of None.



15
16
17
18
19
20
21
# File 'lib/hrr_rb_ssh/authentication/method/none.rb', line 15

def initialize transport, options, variables, authentication_methods, logger: nil
  self.logger = logger
  @transport = transport
  @authenticator = options.fetch( 'authentication_none_authenticator', Authenticator.new{ false } )
  @variables = variables
  @authentication_methods = authentication_methods
end

Instance Method Details

#authenticate(userauth_request_message) ⇒ Object



23
24
25
26
27
# File 'lib/hrr_rb_ssh/authentication/method/none.rb', line 23

def authenticate userauth_request_message
  log_info { "authenticate" }
  context = Context.new(userauth_request_message[:'user name'], @variables, @authentication_methods, logger: logger)
  @authenticator.authenticate context
end

#request_authentication(username, service_name) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hrr_rb_ssh/authentication/method/none.rb', line 29

def request_authentication username, service_name
  message = {
    :'message number' => Message::SSH_MSG_USERAUTH_REQUEST::VALUE,
    :"user name"      => username,
    :"service name"   => service_name,
    :"method name"    => NAME,
  }
  payload = Message::SSH_MSG_USERAUTH_REQUEST.new(logger: logger).encode message
  @transport.send payload
  payload = @transport.receive
end