Sha256: 299f5c39642ce1995ba796d6e3bea039a2f6728d6c42af6e6e8cb4da5a978369

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

module Dkdeploy
  module InteractionHandler
    # Interaction handler for password
    class Password
      # Interaction handler for password
      #
      # @attr [String] password The password to send to terminal
      def initialize(password)
        @password = password
      end

      # Method to send password to terminal
      #
      # @param [SSHKit::Command] _command
      # @param [Symbol] _stream_name
      # @param [String] data
      # @param [Net::SSH::Connection::Channel] channel
      def on_data(_command, _stream_name, data, channel)
        if data =~ /.*password.*/i
          channel.send_data("#{@password}\n")
        else
          channel.close
          raise 'Unexpected data from stream. Can not send password to undefined stream'
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dkdeploy-core-9.1.1 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.0.1 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.1.0 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.0.0 lib/dkdeploy/interaction_handler/password.rb