Class: Net::SSH::Authentication::Methods::Abstract
- Inherits:
-
Object
- Object
- Net::SSH::Authentication::Methods::Abstract
- Defined in:
- lib/net/ssh/authentication/methods/abstract.rb
Overview
The base class of all user authentication methods. It provides a few bits of common functionality.
Direct Known Subclasses
Constant Summary
Constants included from Constants
Constants::USERAUTH_BANNER, Constants::USERAUTH_FAILURE, Constants::USERAUTH_METHOD_RANGE, Constants::USERAUTH_PASSWD_CHANGEREQ, Constants::USERAUTH_PK_OK, Constants::USERAUTH_REQUEST, Constants::USERAUTH_SUCCESS
Instance Attribute Summary collapse
-
#key_manager ⇒ Object
readonly
The key manager object.
-
#session ⇒ Object
readonly
The authentication session object.
Attributes included from Loggable
Instance Method Summary collapse
-
#initialize(session, options = {}) ⇒ Abstract
constructor
Instantiates a new authentication method.
-
#send_message(msg) ⇒ Object
Sends a message via the underlying transport layer abstraction.
-
#session_id ⇒ Object
Returns the session-id, as generated during the first key exchange of an SSH connection.
-
#userauth_request(username, next_service, auth_method, *others) ⇒ Object
Creates a new USERAUTH_REQUEST packet.
Methods included from Loggable
#debug, #error, #fatal, #info, #lwarn
Constructor Details
#initialize(session, options = {}) ⇒ Abstract
Instantiates a new authentication method.
21 22 23 24 25 26 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 21 def initialize(session, ={}) @session = session @key_manager = [:key_manager] @options = self.logger = session.logger end |
Instance Attribute Details
#key_manager ⇒ Object (readonly)
The key manager object. Not all authentication methods will require this.
18 19 20 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 18 def key_manager @key_manager end |
#session ⇒ Object (readonly)
The authentication session object
14 15 16 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 14 def session @session end |
Instance Method Details
#send_message(msg) ⇒ Object
Sends a message via the underlying transport layer abstraction. This will block until the message is completely sent.
36 37 38 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 36 def (msg) session.transport.(msg) end |
#session_id ⇒ Object
Returns the session-id, as generated during the first key exchange of an SSH connection.
30 31 32 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 30 def session_id session.transport.algorithms.session_id end |
#userauth_request(username, next_service, auth_method, *others) ⇒ Object
Creates a new USERAUTH_REQUEST packet. The extra arguments on the end must be either boolean values or strings, and are tacked onto the end of the packet. The new packet is returned, ready for sending.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/net/ssh/authentication/methods/abstract.rb', line 43 def userauth_request(username, next_service, auth_method, *others) buffer = Net::SSH::Buffer.from(:byte, USERAUTH_REQUEST, :string, username, :string, next_service, :string, auth_method) others.each do |value| case value when true, false then buffer.write_bool(value) when String then buffer.write_string(value) else raise ArgumentError, "don't know how to write #{value.inspect}" end end buffer end |