Fix bunch of warnings

This commit is contained in:
Jeroen van Erp
2023-10-11 22:41:50 +02:00
parent 5d040dd4bb
commit a3cce0d2f9
7 changed files with 23 additions and 11 deletions

View File

@@ -214,6 +214,9 @@ public class SshdContainer extends GenericContainer<SshdContainer> {
case STDERR: case STDERR:
logger().info("sshd stderr: {}", outputFrame.getUtf8String().stripTrailing()); logger().info("sshd stderr: {}", outputFrame.getUtf8String().stripTrailing());
break; break;
case END:
break;
} }
}); });
} }

View File

@@ -26,7 +26,6 @@ import org.junit.jupiter.params.provider.ValueSource;
import com.hierynomus.sshj.SshdContainer; import com.hierynomus.sshj.SshdContainer;
import com.hierynomus.sshj.SshdContainer.SshdConfigBuilder; import com.hierynomus.sshj.SshdContainer.SshdConfigBuilder;
import net.schmizz.sshj.Config;
import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.DefaultConfig;
import net.schmizz.sshj.SSHClient; import net.schmizz.sshj.SSHClient;
import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts; import net.schmizz.sshj.transport.verification.OpenSSHKnownHosts;

View File

@@ -26,7 +26,6 @@ import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.junit.jupiter.Testcontainers;
import com.hierynomus.sshj.SshdContainer; import com.hierynomus.sshj.SshdContainer;
import com.hierynomus.sshj.transport.mac.Macs;
import net.schmizz.sshj.Config; import net.schmizz.sshj.Config;
import net.schmizz.sshj.DefaultConfig; import net.schmizz.sshj.DefaultConfig;

View File

@@ -22,9 +22,6 @@ import net.schmizz.sshj.signature.SignatureDSA;
import net.schmizz.sshj.signature.SignatureECDSA; import net.schmizz.sshj.signature.SignatureECDSA;
import net.schmizz.sshj.signature.SignatureRSA; import net.schmizz.sshj.signature.SignatureRSA;
import java.util.Arrays;
import java.util.List;
public class KeyAlgorithms { public class KeyAlgorithms {
public static Factory SSHRSA() { return new Factory("ssh-rsa", new SignatureRSA.FactorySSHRSA(), KeyType.RSA); } public static Factory SSHRSA() { return new Factory("ssh-rsa", new SignatureRSA.FactorySSHRSA(), KeyType.RSA); }

View File

@@ -28,7 +28,6 @@ import net.schmizz.sshj.connection.channel.forwarded.RemotePortForwarder.Forward
import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder; import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder;
import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder.X11Channel; import net.schmizz.sshj.connection.channel.forwarded.X11Forwarder.X11Channel;
import net.schmizz.sshj.sftp.SFTPClient; import net.schmizz.sshj.sftp.SFTPClient;
import net.schmizz.sshj.sftp.SFTPEngine;
import net.schmizz.sshj.sftp.StatefulSFTPClient; import net.schmizz.sshj.sftp.StatefulSFTPClient;
import net.schmizz.sshj.transport.Transport; import net.schmizz.sshj.transport.Transport;
import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.transport.TransportException;
@@ -733,7 +732,7 @@ public class SSHClient
throws IOException { throws IOException {
checkConnected(); checkConnected();
checkAuthenticated(); checkAuthenticated();
return new SFTPClient(new SFTPEngine(this).init()); return new SFTPClient(this);
} }
/** /**
@@ -746,7 +745,7 @@ public class SSHClient
throws IOException { throws IOException {
checkConnected(); checkConnected();
checkAuthenticated(); checkAuthenticated();
return new StatefulSFTPClient(new SFTPEngine(this).init()); return new StatefulSFTPClient(this);
} }
/** /**

View File

@@ -15,6 +15,7 @@
*/ */
package net.schmizz.sshj.sftp; package net.schmizz.sshj.sftp;
import net.schmizz.sshj.connection.channel.direct.SessionFactory;
import net.schmizz.sshj.xfer.FilePermission; import net.schmizz.sshj.xfer.FilePermission;
import net.schmizz.sshj.xfer.LocalDestFile; import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile; import net.schmizz.sshj.xfer.LocalSourceFile;
@@ -39,6 +40,13 @@ public class SFTPClient
this.xfer = new SFTPFileTransfer(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() { public SFTPEngine getSFTPEngine() {
return engine; return engine;
} }
@@ -232,7 +240,7 @@ public class SFTPClient
throws IOException { throws IOException {
xfer.download(source, dest); xfer.download(source, dest);
} }
public void get(String source, String dest, long byteOffset) public void get(String source, String dest, long byteOffset)
throws IOException { throws IOException {
xfer.download(source, dest, byteOffset); xfer.download(source, dest, byteOffset);
@@ -252,7 +260,7 @@ public class SFTPClient
throws IOException { throws IOException {
xfer.download(source, dest); xfer.download(source, dest);
} }
public void get(String source, LocalDestFile dest, long byteOffset) public void get(String source, LocalDestFile dest, long byteOffset)
throws IOException { throws IOException {
xfer.download(source, dest, byteOffset); xfer.download(source, dest, byteOffset);
@@ -262,7 +270,7 @@ public class SFTPClient
throws IOException { throws IOException {
xfer.upload(source, dest); xfer.upload(source, dest);
} }
public void put(LocalSourceFile source, String dest, long byteOffset) public void put(LocalSourceFile source, String dest, long byteOffset)
throws IOException { throws IOException {
xfer.upload(source, dest, byteOffset); xfer.upload(source, dest, byteOffset);

View File

@@ -15,6 +15,7 @@
*/ */
package net.schmizz.sshj.sftp; package net.schmizz.sshj.sftp;
import net.schmizz.sshj.connection.channel.direct.SessionFactory;
import net.schmizz.sshj.xfer.LocalDestFile; import net.schmizz.sshj.xfer.LocalDestFile;
import net.schmizz.sshj.xfer.LocalSourceFile; import net.schmizz.sshj.xfer.LocalSourceFile;
@@ -34,6 +35,12 @@ public class StatefulSFTPClient
log.debug("Start dir = {}", cwd); 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) { private synchronized String cwdify(String path) {
return engine.getPathHelper().adjustForParent(cwd, path); return engine.getPathHelper().adjustForParent(cwd, path);
} }