Browse Source

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>
stable-4.5
markdingram 9 years ago committed by Matthias Sohn
parent
commit
583b34483a
  1. 16
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

16
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…
Cancel
Save