Set JSch global config values only if not set already
Bug: 576604 Change-Id: I04415f07bf2023bc8435c097d1d3c65221d563f1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
7d4f3c22ab
commit
f8b0c00e6a
|
@ -45,6 +45,7 @@
|
||||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||||
import org.eclipse.jgit.transport.URIish;
|
import org.eclipse.jgit.transport.URIish;
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
|
import org.eclipse.jgit.util.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -417,14 +418,26 @@ protected JSch getJSch(OpenSshConfig.Host hc, FS fs) throws JSchException {
|
||||||
*/
|
*/
|
||||||
protected JSch createDefaultJSch(FS fs) throws JSchException {
|
protected JSch createDefaultJSch(FS fs) throws JSchException {
|
||||||
final JSch jsch = new JSch();
|
final JSch jsch = new JSch();
|
||||||
JSch.setConfig("ssh-rsa", JSch.getConfig("signature.rsa")); //$NON-NLS-1$ //$NON-NLS-2$
|
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=537790 and
|
||||||
JSch.setConfig("ssh-dss", JSch.getConfig("signature.dss")); //$NON-NLS-1$ //$NON-NLS-2$
|
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=576604
|
||||||
|
copyGlobalConfigIfNotSet("signature.rsa", "ssh-rsa"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
copyGlobalConfigIfNotSet("signature.dss", "ssh-dss"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
configureJSch(jsch);
|
configureJSch(jsch);
|
||||||
knownHosts(jsch, fs);
|
knownHosts(jsch, fs);
|
||||||
identities(jsch, fs);
|
identities(jsch, fs);
|
||||||
return jsch;
|
return jsch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyGlobalConfigIfNotSet(String from, String to) {
|
||||||
|
String toValue = JSch.getConfig(to);
|
||||||
|
if (StringUtils.isEmptyOrNull(toValue)) {
|
||||||
|
String fromValue = JSch.getConfig(from);
|
||||||
|
if (!StringUtils.isEmptyOrNull(fromValue)) {
|
||||||
|
JSch.setConfig(to, fromValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void knownHosts(JSch sch, FS fs) throws JSchException {
|
private static void knownHosts(JSch sch, FS fs) throws JSchException {
|
||||||
final File home = fs.userHome();
|
final File home = fs.userHome();
|
||||||
if (home == null)
|
if (home == null)
|
||||||
|
|
Loading…
Reference in New Issue