Sha256: 31c86512800b653fdaeef5629d9efe389876d05b3843e773a33f875aeb51a1f7

Contents?: true

Size: 1.9 KB

Versions: 34

Compression:

Stored size: 1.9 KB

Contents

require 'net/ssh/buffer'
require 'net/ssh/errors'
require 'net/ssh/loggable'
require 'net/ssh/authentication/constants'

module Net; module SSH; module Authentication; module Methods

  # The base class of all user authentication methods. It provides a few
  # bits of common functionality.
  class Abstract
    include Constants, Loggable

    # The authentication session object
    attr_reader :session

    # The key manager object. Not all authentication methods will require
    # this.
    attr_reader :key_manager

    # Instantiates a new authentication method.
    def initialize(session, options={})
      @session = session
      @key_manager = options[:key_manager]
      @options = options
      @prompt = options[:password_prompt]
      self.logger = session.logger
    end

    # Returns the session-id, as generated during the first key exchange of
    # an SSH connection.
    def session_id
      session.transport.algorithms.session_id
    end

    # Sends a message via the underlying transport layer abstraction. This
    # will block until the message is completely sent.
    def send_message(msg)
      session.transport.send_message(msg)
    end

    # 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.
    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

    private

    attr_reader :prompt
  end

end; end; end; end

Version data entries

34 entries across 31 versions & 3 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.1.1.0 vendor/bundle/ruby/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.4.0 vendor/bundle/ruby/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.3.0 vendor/bundle/ruby/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
net-ssh-5.0.0.beta1 lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/net-ssh-4.2.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
net-ssh-4.2.0 lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
net-ssh-4.2.0.rc2 lib/net/ssh/authentication/methods/abstract.rb
net-ssh-4.2.0.rc1 lib/net/ssh/authentication/methods/abstract.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/net-ssh-4.1.0/lib/net/ssh/authentication/methods/abstract.rb
net-ssh-4.1.0 lib/net/ssh/authentication/methods/abstract.rb