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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, algorithm, session_id, message) ⇒ Context

Returns a new instance of Context.



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

def initialize username, algorithm, session_id, message
  @username   = username
  @algorithm  = algorithm
  @session_id = session_id
  @message    = message

  @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

#message_numberObject (readonly)

Returns the value of attribute message_number.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def message_number
  @message_number
end

#method_nameObject (readonly)

Returns the value of attribute method_name.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def method_name
  @method_name
end

#public_key_algorithm_nameObject (readonly)

Returns the value of attribute public_key_algorithm_name.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def public_key_algorithm_name
  @public_key_algorithm_name
end

#public_key_blobObject (readonly)

Returns the value of attribute public_key_blob.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def public_key_blob
  @public_key_blob
end

#service_nameObject (readonly)

Returns the value of attribute service_name.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def service_name
  @service_name
end

#session_idObject (readonly)

Returns the value of attribute session_id.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def session_id
  @session_id
end

#signatureObject (readonly)

Returns the value of attribute signature.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def signature
  @signature
end

#usernameObject (readonly)

Returns the value of attribute username.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def username
  @username
end

#with_signatureObject (readonly)

Returns the value of attribute with_signature.



11
12
13
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 11

def with_signature
  @with_signature
end

Instance Method Details

#verify(username, public_key_algorithm_name, public_key) ⇒ Object



37
38
39
40
41
42
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 37

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



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

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



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

def verify_public_key_algorithm_name public_key_algorithm_name
  public_key_algorithm_name == @public_key_algorithm_name
end

#verify_signatureObject



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

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

#verify_username(username) ⇒ Object



44
45
46
# File 'lib/hrr_rb_ssh/authentication/method/publickey/context.rb', line 44

def verify_username username
  username == @username
end