Class: RJGit::RubyGit::RJGitSSHConfigCallback

Inherits:
Object
  • Object
show all
Includes:
TransportConfigCallback
Defined in:
lib/git.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ RJGitSSHConfigCallback

Returns a new instance of RJGitSSHConfigCallback.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/git.rb', line 139

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

Instance Method Details

#configure(ssh_transport) ⇒ Object



174
175
176
# File 'lib/git.rb', line 174

def configure(ssh_transport)
  ssh_transport.setSshSessionFactory(@sshSessionFactory)
end