diff --git a/src/itest/java/com/hierynomus/sshj/SshdContainer.java b/src/itest/java/com/hierynomus/sshj/SshdContainer.java index 60ea632c..82cfda64 100644 --- a/src/itest/java/com/hierynomus/sshj/SshdContainer.java +++ b/src/itest/java/com/hierynomus/sshj/SshdContainer.java @@ -214,6 +214,9 @@ public SshdContainer(@NotNull Future future) { case STDERR: logger().info("sshd stderr: {}", outputFrame.getUtf8String().stripTrailing()); break; + case END: + break; + } }); } diff --git a/src/itest/java/com/hierynomus/sshj/signature/HostKeyWithCertificateTest.java b/src/itest/java/com/hierynomus/sshj/signature/HostKeyWithCertificateTest.java index 22c761e0..1d22693b 100644 --- a/src/itest/java/com/hierynomus/sshj/signature/HostKeyWithCertificateTest.java +++ b/src/itest/java/com/hierynomus/sshj/signature/HostKeyWithCertificateTest.java @@ -26,7 +26,6 @@ import com.hierynomus.sshj.SshdContainer; import com.hierynomus.sshj.SshdContainer.SshdConfigBuilder; -import net.schmizz.sshj.Config; import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts; diff --git a/src/itest/java/com/hierynomus/sshj/transport/kex/KexTest.java b/src/itest/java/com/hierynomus/sshj/transport/kex/KexTest.java index 5a192971..fd3c7e9f 100644 --- a/src/itest/java/com/hierynomus/sshj/transport/kex/KexTest.java +++ b/src/itest/java/com/hierynomus/sshj/transport/kex/KexTest.java @@ -26,7 +26,6 @@ import org.testcontainers.junit.jupiter.Testcontainers; import com.hierynomus.sshj.SshdContainer; -import com.hierynomus.sshj.transport.mac.Macs; import net.schmizz.sshj.Config; import net.schmizz.sshj.DefaultConfig; diff --git a/src/main/java/com/hierynomus/sshj/key/KeyAlgorithms.java b/src/main/java/com/hierynomus/sshj/key/KeyAlgorithms.java index 81891345..7193a4bd 100644 --- a/src/main/java/com/hierynomus/sshj/key/KeyAlgorithms.java +++ b/src/main/java/com/hierynomus/sshj/key/KeyAlgorithms.java @@ -22,9 +22,6 @@ import net.schmizz.sshj.signature.SignatureECDSA; import net.schmizz.sshj.signature.SignatureRSA; -import java.util.Arrays; -import java.util.List; - public class KeyAlgorithms { public static Factory SSHRSA() { return new Factory("ssh-rsa", new SignatureRSA.FactorySSHRSA(), KeyType.RSA); } diff --git a/src/main/java/net/schmizz/sshj/SSHClient.java b/src/main/java/net/schmizz/sshj/SSHClient.java index 5c99d800..dd0e3817 100644 --- a/src/main/java/net/schmizz/sshj/SSHClient.java +++ b/src/main/java/net/schmizz/sshj/SSHClient.java @@ -28,7 +28,6 @@ import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder; import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder.X11Channel; import net.schmizz.sshj.sftp.SFTPClient; -import net.schmizz.sshj.sftp.SFTPEngine; import net.schmizz.sshj.sftp.StatefulSFTPClient; import net.schmizz.sshj.transport.Transport; import net.schmizz.sshj.transport.TransportException; @@ -733,7 +732,7 @@ public SFTPClient newSFTPClient() throws IOException { checkConnected(); checkAuthenticated(); - return new SFTPClient(new SFTPEngine(this).init()); + return new SFTPClient(this); } /** @@ -746,7 +745,7 @@ public StatefulSFTPClient newStatefulSFTPClient() throws IOException { checkConnected(); checkAuthenticated(); - return new StatefulSFTPClient(new SFTPEngine(this).init()); + return new StatefulSFTPClient(this); } /** diff --git a/src/main/java/net/schmizz/sshj/sftp/SFTPClient.java b/src/main/java/net/schmizz/sshj/sftp/SFTPClient.java index 2ea5c333..af9d7065 100644 --- a/src/main/java/net/schmizz/sshj/sftp/SFTPClient.java +++ b/src/main/java/net/schmizz/sshj/sftp/SFTPClient.java @@ -15,6 +15,7 @@ */ package net.schmizz.sshj.sftp; +import net.schmizz.sshj.connection.channel.direct.SessionFactory; import net.schmizz.sshj.xfer.FilePermission; import net.schmizz.sshj.xfer.LocalDestFile; import net.schmizz.sshj.xfer.LocalSourceFile; @@ -39,6 +40,13 @@ public SFTPClient(SFTPEngine engine) { this.xfer = new SFTPFileTransfer(engine); } + public SFTPClient(SessionFactory sessionFactory) throws IOException { + this.engine = new SFTPEngine(sessionFactory); + this.engine.init(); + log = engine.getLoggerFactory().getLogger(getClass()); + this.xfer = new SFTPFileTransfer(engine); + } + public SFTPEngine getSFTPEngine() { return engine; } @@ -232,7 +240,7 @@ public void get(String source, String dest) throws IOException { xfer.download(source, dest); } - + public void get(String source, String dest, long byteOffset) throws IOException { xfer.download(source, dest, byteOffset); @@ -252,7 +260,7 @@ public void get(String source, LocalDestFile dest) throws IOException { xfer.download(source, dest); } - + public void get(String source, LocalDestFile dest, long byteOffset) throws IOException { xfer.download(source, dest, byteOffset); @@ -262,7 +270,7 @@ public void put(LocalSourceFile source, String dest) throws IOException { xfer.upload(source, dest); } - + public void put(LocalSourceFile source, String dest, long byteOffset) throws IOException { xfer.upload(source, dest, byteOffset); diff --git a/src/main/java/net/schmizz/sshj/sftp/StatefulSFTPClient.java b/src/main/java/net/schmizz/sshj/sftp/StatefulSFTPClient.java index a9475d7e..4f31d0e8 100644 --- a/src/main/java/net/schmizz/sshj/sftp/StatefulSFTPClient.java +++ b/src/main/java/net/schmizz/sshj/sftp/StatefulSFTPClient.java @@ -15,6 +15,7 @@ */ package net.schmizz.sshj.sftp; +import net.schmizz.sshj.connection.channel.direct.SessionFactory; import net.schmizz.sshj.xfer.LocalDestFile; import net.schmizz.sshj.xfer.LocalSourceFile; @@ -34,6 +35,12 @@ public StatefulSFTPClient(SFTPEngine engine) log.debug("Start dir = {}", cwd); } + public StatefulSFTPClient(SessionFactory sessionFactory) throws IOException { + super(sessionFactory); + this.cwd = getSFTPEngine().canonicalize("."); + log.debug("Start dir = {}", cwd); + } + private synchronized String cwdify(String path) { return engine.getPathHelper().adjustForParent(cwd, path); }