瀏覽代碼

Add configureJSch method to allow configuration of JSch objects

Example use case is to set a different IdentityRepository, for example,
a RemoteIdentityRepository to allow SSH Agent supplied credentials.

Change-Id: Id4a4afd64464e452ffe6d6ad49036f9e283b4655
Signed-off-by: markdingram <markdingram@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v4.5.0.201609210915-r
markdingram 8 年之前
父節點
當前提交
583b34483a
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16
    0
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

+ 16
- 0
org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java 查看文件

@@ -1,4 +1,5 @@
/*
* Copyright (C) 2016, Mark Ingram <markdingram@gmail.com>
* Copyright (C) 2009, Constantine Plotnikov <constantine.plotnikov@gmail.com>
* Copyright (C) 2008-2009, Google Inc.
* Copyright (C) 2009, Google, Inc.
@@ -219,6 +220,19 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
return getJSch(hc, fs).getSession(user, host, port);
}

/**
* Provide additional configuration for the JSch instance. This method could
* be overridden to supply a preferred
* {@link com.jcraft.jsch.IdentityRepository}.
*
* @param jsch
* jsch instance
* @since 4.5
*/
protected void configureJSch(JSch jsch) {
// No additional configuration required.
}

/**
* Provide additional configuration for the session based on the host
* information. This method could be used to supply {@link UserInfo}.
@@ -257,6 +271,7 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
JSch jsch = byIdentityFile.get(identityKey);
if (jsch == null) {
jsch = new JSch();
configureJSch(jsch);
jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository());
jsch.addIdentity(identityKey);
byIdentityFile.put(identityKey, jsch);
@@ -274,6 +289,7 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
*/
protected JSch createDefaultJSch(FS fs) throws JSchException {
final JSch jsch = new JSch();
configureJSch(jsch);
knownHosts(jsch, fs);
identities(jsch, fs);
return jsch;

Loading…
取消
儲存