class RJGit::RubyGit::RJGitSSHConfigCallback

Public Class Methods

new(options = {}) click to toggle source
# File lib/git.rb, line 134
def initialize(options = {})
  @sshSessionFactory = Class.new(JschConfigSessionFactory) {
    def initialize(options)
      super()
      @private_key_file = options[:private_key_file]
      @private_key_passphrase = options[:private_key_passphrase]
      @username = options[:username]
      @password = options[:password]
      @known_hosts_file = options[:known_hosts_file]
    end

    def configure(host, session)
      session.setUserName(@username) if @username
      session.setPassword(@password) if @password
    end

    def createDefaultJSch(fs)
      default_j_sch = super(fs)
      if @private_key_file
        default_j_sch.removeAllIdentity()
        if @private_key_passphrase
          default_j_sch.addIdentity(@private_key_file, @private_key_passphrase)
        else
          default_j_sch.addIdentity(@private_key_file)
        end
      end
      if @known_hosts_file
        default_j_sch.setKnownHosts(@known_hosts_file)
      end

      return default_j_sch
    end
  }.new(options)
end

Public Instance Methods

configure(host, session) click to toggle source
# File lib/git.rb, line 145
def configure(host, session)
  session.setUserName(@username) if @username
  session.setPassword(@password) if @password
end
createDefaultJSch(fs) click to toggle source
Calls superclass method
# File lib/git.rb, line 150
def createDefaultJSch(fs)
  default_j_sch = super(fs)
  if @private_key_file
    default_j_sch.removeAllIdentity()
    if @private_key_passphrase
      default_j_sch.addIdentity(@private_key_file, @private_key_passphrase)
    else
      default_j_sch.addIdentity(@private_key_file)
    end
  end
  if @known_hosts_file
    default_j_sch.setKnownHosts(@known_hosts_file)
  end

  return default_j_sch
end