Class: HrrRbSsh::Authentication::Method::Publickey::Context

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/hrr_rb_ssh/authentication/method/publickey/context.rb

Instance Attribute Summary collapse

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

Constructor Details

#initialize(username, algorithm, session_id, message, variables, authentication_methods, logger: nil) ⇒ Context

Returns a new instance of Context.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 27

def initialize username, algorithm, session_id, message, variables, authentication_methods, logger: nil
  self.logger = logger
  @username   = username
  @algorithm  = algorithm
  @session_id = session_id
  @message    = message
  @variables  = variables
  @vars       = variables
  @authentication_methods = authentication_methods

  @message_number            = message[:'message number']
  @service_name              = message[:'service name']
  @method_name               = message[:'method name']
  @with_signature            = message[:'with signature']
  @public_key_algorithm_name = message[:'public key algorithm name']
  @public_key_blob           = message[:'public key blob']
  @signature                 = message[:'signature']
end

Instance Attribute Details

#authentication_methodsObject (readonly)

Returns the value of attribute authentication_methods.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def authentication_methods
  @authentication_methods
end

#message_numberObject (readonly)

Returns the value of attribute message_number.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def message_number
  @message_number
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def method_name
  @method_name
end

#public_key_algorithm_nameObject (readonly)

Returns the value of attribute public_key_algorithm_name.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def public_key_algorithm_name
  @public_key_algorithm_name
end

#public_key_blobObject (readonly)

Returns the value of attribute public_key_blob.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def public_key_blob
  @public_key_blob
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def service_name
  @service_name
end

#session_idObject (readonly)

Returns the value of attribute session_id.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def session_id
  @session_id
end

#signatureObject (readonly)

Returns the value of attribute signature.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def signature
  @signature
end

#usernameObject (readonly)

Returns the value of attribute username.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def username
  @username
end

#variablesObject (readonly)

Returns the value of attribute variables.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def variables
  @variables
end

#varsObject (readonly)

Returns the value of attribute vars.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def vars
  @vars
end

#with_signatureObject (readonly)

Returns the value of attribute with_signature.



13
14
15
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 13

def with_signature
  @with_signature
end

Instance Method Details

#verify(username, public_key_algorithm_name, public_key) ⇒ Object



46
47
48
49
50
51
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 46

def verify username, public_key_algorithm_name, public_key
    verify_username(username) \
    && verify_public_key_algorithm_name(public_key_algorithm_name) \
    && verify_public_key(public_key_algorithm_name, public_key) \
    && verify_signature
end

#verify_public_key(public_key_algorithm_name, public_key) ⇒ Object



61
62
63
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 61

def verify_public_key public_key_algorithm_name, public_key
  @algorithm.verify_public_key(public_key_algorithm_name, public_key, @public_key_blob)
end

#verify_public_key_algorithm_name(public_key_algorithm_name) ⇒ Object



57
58
59
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 57

def verify_public_key_algorithm_name public_key_algorithm_name
  public_key_algorithm_name == @public_key_algorithm_name
end

#verify_signatureObject



65
66
67
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 65

def verify_signature
  @algorithm.verify_signature(@session_id, @message)
end

#verify_username(username) ⇒ Object



53
54
55
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 53

def verify_username username
  username == @username
end