aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authormarkdingram <markdingram@gmail.com>2016-06-21 17:31:20 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-07-01 22:34:29 +0200
commit583b34483abf752a1afb2e62930ce04927b40022 (patch)
tree9e45766020173b030b5c44510b9785071fee563b /org.eclipse.jgit
parent13db3550a4858c7d21a21a3df21f54dda936ec66 (diff)
downloadjgit-583b34483abf752a1afb2e62930ce04927b40022.tar.gz
jgit-583b34483abf752a1afb2e62930ce04927b40022.zip
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>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
index 308741e935..d1cbd8d268 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java
+++ b/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.
@@ -220,6 +221,19 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
}
/**
+ * 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;