Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2021-10-19 05:38:54 -0400
committerGerrit Code Review @ Eclipse.org2021-10-19 05:38:54 -0400
commitc0436a3a0ab197b4e9639c0f2d94a386dc91d12a (patch)
tree0cba71ee51d49cfc4689693925e7b5f5ee90cad5
parent8a3158c551fabdce759cecdc61ee3aff50f0bd50 (diff)
parentf698fbf919c67edac4b3999cc932c1f22da1dffd (diff)
downloadjgit-c0436a3a0ab197b4e9639c0f2d94a386dc91d12a.tar.gz
jgit-c0436a3a0ab197b4e9639c0f2d94a386dc91d12a.tar.xz
jgit-c0436a3a0ab197b4e9639c0f2d94a386dc91d12a.zip
Merge changes I1f180d7f,I04415f07
* changes: JSch: fix service publication for ServiceLoader Set JSch global config values only if not set already
-rw-r--r--org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/ssh/jsch/ServiceLoaderTest.java24
-rw-r--r--org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory (renamed from org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.ssh.jsch.SshSessionFactory)0
-rw-r--r--org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java17
3 files changed, 39 insertions, 2 deletions
diff --git a/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/ssh/jsch/ServiceLoaderTest.java b/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/ssh/jsch/ServiceLoaderTest.java
new file mode 100644
index 0000000000..2bae221e29
--- /dev/null
+++ b/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit/transport/ssh/jsch/ServiceLoaderTest.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021, Thomas Wolf <thomas.wolf@paranor.ch> and others
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.transport.ssh.jsch;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.eclipse.jgit.transport.SshSessionFactory;
+import org.junit.Test;
+
+public class ServiceLoaderTest {
+
+ @Test
+ public void testDefaultFactoryFound() {
+ SshSessionFactory defaultFactory = SshSessionFactory.getInstance();
+ assertNotNull(defaultFactory);
+ }
+}
diff --git a/org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.ssh.jsch.SshSessionFactory b/org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory
index aca489659e..aca489659e 100644
--- a/org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.ssh.jsch.SshSessionFactory
+++ b/org.eclipse.jgit.ssh.jsch/resources/META-INF/services/org.eclipse.jgit.transport.SshSessionFactory
diff --git a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java
index 453433e0c4..77b68bb034 100644
--- a/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java
+++ b/org.eclipse.jgit.ssh.jsch/src/org/eclipse/jgit/transport/ssh/jsch/JschConfigSessionFactory.java
@@ -45,6 +45,7 @@ import org.eclipse.jgit.transport.SshConstants;
import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.util.FS;
+import org.eclipse.jgit.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -417,14 +418,26 @@ public class JschConfigSessionFactory extends SshSessionFactory {
*/
protected JSch createDefaultJSch(FS fs) throws JSchException {
final JSch jsch = new JSch();
- JSch.setConfig("ssh-rsa", JSch.getConfig("signature.rsa")); //$NON-NLS-1$ //$NON-NLS-2$
- JSch.setConfig("ssh-dss", JSch.getConfig("signature.dss")); //$NON-NLS-1$ //$NON-NLS-2$
+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=537790 and
+ // 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);
knownHosts(jsch, fs);
identities(jsch, fs);
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 {
final File home = fs.userHome();
if (home == null)

Back to the top