aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit.ssh/src
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2019-01-14 17:30:03 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2019-05-06 15:22:05 +0200
commit86cee68e0d9282ecc6a49792693309e8d5d9d984 (patch)
tree7a4745417f0bcbd9f5e998f21f4703db38ee19c2 /org.eclipse.jgit.junit.ssh/src
parent756c2c2b3c9be5f9c487c08de868acaeb43348d9 (diff)
downloadjgit-86cee68e0d9282ecc6a49792693309e8d5d9d984.tar.gz
jgit-86cee68e0d9282ecc6a49792693309e8d5d9d984.zip
Apache MINA sshd client: adapt to sshd 2.2.0
Update target platforms, maven and bazel builds to use sshd 2.2.0. Adapt internal classes to changed sshd interfaces and remove previous work-arounds for asking repeatedly for key passwords and for loading keys lazily; both are now done by sshd. CQ: 19034 CQ: 19035 Bug: 541425 Change-Id: I85e1df6ebb8a94953a912d9b2b8a7b5bdfbd608a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit.ssh/src')
-rw-r--r--org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
index f5af2e5ce1..25d952f189 100644
--- a/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
+++ b/org.eclipse.jgit.junit.ssh/src/org/eclipse/jgit/junit/ssh/SshTestGitServer.java
@@ -55,10 +55,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.config.keys.AuthorizedKeyEntry;
import org.apache.sshd.common.config.keys.KeyUtils;
@@ -67,6 +66,8 @@ import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.security.SecurityUtils;
+import org.apache.sshd.common.util.threads.CloseableExecutorService;
+import org.apache.sshd.common.util.threads.ThreadUtils;
import org.apache.sshd.server.ServerAuthenticationManager;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.UserAuth;
@@ -110,8 +111,8 @@ public class SshTestGitServer {
@NonNull
protected PublicKey testKey;
- private final ExecutorService executorService = Executors
- .newFixedThreadPool(2);
+ private final CloseableExecutorService executorService = ThreadUtils
+ .newFixedThreadPool("SshTestGitServerPool", 2);
/**
* Creates a ssh git <em>test</em> server. It serves one single repository,
@@ -138,11 +139,12 @@ public class SshTestGitServer {
server = SshServer.setUpDefaultServer();
// Set host key
try (ByteArrayInputStream in = new ByteArrayInputStream(hostKey)) {
- hostKeys.add(SecurityUtils.loadKeyPairIdentity("", in, null));
+ SecurityUtils.loadKeyPairIdentities(null, null, in, null)
+ .forEach((k) -> hostKeys.add(k));
} catch (IOException | GeneralSecurityException e) {
// Ignore.
}
- server.setKeyPairProvider(() -> hostKeys);
+ server.setKeyPairProvider((session) -> hostKeys);
configureAuthentication();
@@ -276,8 +278,10 @@ public class SshTestGitServer {
public void addHostKey(@NonNull Path key, boolean inFront)
throws IOException, GeneralSecurityException {
try (InputStream in = Files.newInputStream(key)) {
- KeyPair pair = SecurityUtils.loadKeyPairIdentity(key.toString(), in,
- null);
+ KeyPair pair = SecurityUtils
+ .loadKeyPairIdentities(null,
+ NamedResource.ofName(key.toString()), in, null)
+ .iterator().next();
if (inFront) {
hostKeys.add(0, pair);
} else {
@@ -335,14 +339,14 @@ public class SshTestGitServer {
public void setTestUserPublicKey(Path key)
throws IOException, GeneralSecurityException {
this.testKey = AuthorizedKeyEntry.readAuthorizedKeys(key).get(0)
- .resolvePublicKey(PublicKeyEntryResolver.IGNORING);
+ .resolvePublicKey(null, PublicKeyEntryResolver.IGNORING);
}
private class GitUploadPackCommand extends AbstractCommandSupport {
protected GitUploadPackCommand(String command,
- ExecutorService executorService) {
- super(command, executorService, false);
+ CloseableExecutorService executorService) {
+ super(command, ThreadUtils.noClose(executorService));
}
@Override
@@ -370,8 +374,8 @@ public class SshTestGitServer {
private class GitReceivePackCommand extends AbstractCommandSupport {
protected GitReceivePackCommand(String command,
- ExecutorService executorService) {
- super(command, executorService, false);
+ CloseableExecutorService executorService) {
+ super(command, ThreadUtils.noClose(executorService));
}
@Override