Skip to content

Commit

Permalink
Merge pull request #792 from citrusframework/fix/bump-ssh-version
Browse files Browse the repository at this point in the history
chore(deps): Bump sshd-core from 2.5.1 to 2.7.0
  • Loading branch information
christophd authored Aug 11, 2021
2 parents 5acdc80 + c67720d commit f2e33eb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
import org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier;
import org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier;
import org.apache.sshd.client.keyverifier.RejectAllServerKeyVerifier;
import org.apache.sshd.client.scp.DefaultScpClientCreator;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.keyprovider.ClassLoadableResourceKeyPairProvider;
import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
import org.apache.sshd.scp.client.DefaultScpClientCreator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
Expand All @@ -49,9 +49,9 @@
public class ScpClient extends SftpClient {

/** Logger */
private static Logger log = LoggerFactory.getLogger(ScpClient.class);
private static final Logger LOG = LoggerFactory.getLogger(ScpClient.class);

private org.apache.sshd.client.scp.ScpClient scpClient;
private org.apache.sshd.scp.client.ScpClient scpClient;

/**
* Default constructor initializing endpoint configuration.
Expand Down Expand Up @@ -93,7 +93,7 @@ protected FtpMessage storeFile(PutCommand command, TestContext context) {
try {
scpClient.upload(FileUtils.getFileResource(command.getFile().getPath(), context).getFile().getAbsolutePath(), command.getTarget().getPath());
} catch (IOException e) {
log.error("Failed to store file via SCP", e);
LOG.error("Failed to store file via SCP", e);
return FtpMessage.error();

}
Expand All @@ -105,12 +105,12 @@ protected FtpMessage retrieveFile(GetCommand command, TestContext context) {
try {
Resource target = FileUtils.getFileResource(command.getTarget().getPath(), context);
if (!Optional.ofNullable(target.getFile().getParentFile()).map(File::mkdirs).orElse(true)) {
log.warn("Failed to create target directories in path: " + target.getFile().getAbsolutePath());
LOG.warn("Failed to create target directories in path: " + target.getFile().getAbsolutePath());
}

scpClient.download(command.getFile().getPath(), target.getFile().getAbsolutePath());
} catch (IOException e) {
log.error("Failed to retrieve file via SCP", e);
LOG.error("Failed to retrieve file via SCP", e);
return FtpMessage.error();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
import com.consol.citrus.xml.StringResult;
import org.apache.commons.net.ftp.FTPCmd;
import org.apache.ftpserver.ftplet.DataType;
import org.apache.sshd.common.scp.ScpTransferEventListener;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.scp.common.ScpTransferEventListener;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.subsystem.sftp.FileHandle;
import org.apache.sshd.server.subsystem.sftp.SftpEventListener;
import org.apache.sshd.sftp.server.FileHandle;
import org.apache.sshd.sftp.server.SftpEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -47,7 +47,7 @@
public class SftpServer extends SshServer implements ScpTransferEventListener, SftpEventListener {

/** Logger */
private static Logger log = LoggerFactory.getLogger(SftpServer.class);
private static final Logger LOG = LoggerFactory.getLogger(SftpServer.class);

/** This servers endpoint configuration */
private final SftpEndpointConfiguration endpointConfiguration;
Expand All @@ -74,8 +74,8 @@ public FtpMessage handleMessage(FtpMessage request) {
request.setPayload(result.toString());
}

if (log.isDebugEnabled()) {
log.debug(String.format("Received request on ftp server: '%s':%n%s",
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Received request on ftp server: '%s':%n%s",
request.getSignal(),
request.getPayload(String.class)));
}
Expand Down Expand Up @@ -113,8 +113,8 @@ public void startFolderEvent(Session session, FileOperation op, Path file, Set<P

@Override
public void initialized(ServerSession session, int version) {
if (log.isDebugEnabled()) {
log.debug(String.format("Received new SFTP connection: '%s'", Arrays.toString(session.getSessionId())));
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Received new SFTP connection: '%s'", Arrays.toString(session.getSessionId())));
}

if (!endpointConfiguration.isAutoConnect()) {
Expand Down Expand Up @@ -152,8 +152,8 @@ public void destroying(ServerSession session) {
}
}

if (log.isDebugEnabled()) {
log.debug(String.format("Closing FTP connection: '%s'", session.getSessionId()));
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Closing FTP connection: '%s'", session.getSessionId()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.apache.sshd.common.keyprovider.ClassLoadableResourceKeyPairProvider;
import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.subsystem.SubsystemFactory;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
import org.apache.sshd.sftp.server.SftpSubsystemFactory;
import org.springframework.core.io.ClassPathResource;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
Expand Down Expand Up @@ -223,6 +223,10 @@ private SshServer startSftpMockServer() throws IOException {
subsystemFactories.add(sftpSubsystemFactory);
sshd.setSubsystemFactories(subsystemFactories);

List<String> availableSignatureFactories = sshd.getSignatureFactoriesNames();
availableSignatureFactories.add("ssh-dss");
sshd.setSignatureFactoriesNames(availableSignatureFactories);

sshd.start();

return sshd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
import org.apache.sshd.common.keyprovider.ClassLoadableResourceKeyPairProvider;
import org.apache.sshd.common.keyprovider.FileKeyPairProvider;
import org.apache.sshd.common.scp.AbstractScpTransferEventListenerAdapter;
import org.apache.sshd.common.scp.ScpTransferEventListener;
import org.apache.sshd.server.scp.ScpCommandFactory;
import org.apache.sshd.scp.common.AbstractScpTransferEventListenerAdapter;
import org.apache.sshd.scp.common.ScpTransferEventListener;
import org.apache.sshd.scp.server.ScpCommandFactory;
import org.apache.sshd.server.subsystem.SubsystemFactory;
import org.apache.sshd.server.subsystem.sftp.AbstractSftpEventListenerAdapter;
import org.apache.sshd.server.subsystem.sftp.SftpEventListener;
import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory;
import org.apache.sshd.sftp.server.AbstractSftpEventListenerAdapter;
import org.apache.sshd.sftp.server.SftpEventListener;
import org.apache.sshd.sftp.server.SftpSubsystemFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;
Expand Down Expand Up @@ -159,6 +159,10 @@ protected void startup() {
sshd.setKeyPairProvider(resourceKeyPairProvider);
}

List<String> availableSignatureFactories = sshd.getSignatureFactoriesNames();
availableSignatureFactories.add("ssh-dss");
sshd.setSignatureFactoriesNames(availableSignatureFactories);

// Authentication
boolean authFound = false;
if (password != null) {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
<zookeeper.version>3.7.0</zookeeper.version>
<dropwizard.metrics.version>4.1.21</dropwizard.metrics.version>
<snappy.version>1.1.8.4</snappy.version>
<sshd.version>2.5.1</sshd.version>
<bouncycastle.version>1.68</bouncycastle.version>
<sshd.version>2.7.0</sshd.version>
<bouncycastle.version>1.69</bouncycastle.version>
<jsch.version>0.1.55</jsch.version>
<json.schema.validator.version>2.2.14</json.schema.validator.version>
<hamcrest.version>2.2</hamcrest.version>
Expand Down

0 comments on commit f2e33eb

Please sign in to comment.