use of org.apache.sshd.server.scp.ScpCommandFactory in project testcases by coheigea.
the class SFTPTest method setup.
@Before
public void setup() throws Exception {
int port = AvailablePortFinder.getNextAvailable(10000);
// Write port number to configuration file in target
String basedir = System.getProperty("basedir");
if (basedir == null) {
basedir = new File(".").getCanonicalPath();
}
// Read in camel configuration file and substitute in the correct port
File f = new File(basedir + "/src/test/resources/camel-sftp.xml");
FileInputStream inputStream = new FileInputStream(f);
String content = IOUtils.toString(inputStream, "UTF-8");
inputStream.close();
content = content.replaceAll("portno", "" + port);
File f2 = new File(basedir + "/target/test-classes/camel-sftp.xml");
FileOutputStream outputStream = new FileOutputStream(f2);
IOUtils.write(content, outputStream, "UTF-8");
outputStream.close();
sshServer = SshServer.setUpDefaultServer();
sshServer.setPort(port);
// Generate a key
sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(Paths.get("target/generatedkey.pem")));
List<NamedFactory<Command>> subsystemFactories = new ArrayList<NamedFactory<Command>>(1);
subsystemFactories.add(new SftpSubsystemFactory());
sshServer.setSubsystemFactories(subsystemFactories);
sshServer.setCommandFactory(new ScpCommandFactory());
sshServer.setPasswordAuthenticator(new CamelPasswordAuthenticator());
sshServer.start();
// Create "storage_sftp" directory (delete it first if it exists)
File storageDirectory = new File(basedir + "/target/storage_sftp");
if (storageDirectory.exists()) {
storageDirectory.delete();
}
storageDirectory.mkdir();
}
use of org.apache.sshd.server.scp.ScpCommandFactory in project testcases by coheigea.
the class SCPTest method setup.
@Before
public void setup() throws Exception {
int port = AvailablePortFinder.getNextAvailable(10000);
// Write port number to configuration file in target
String basedir = System.getProperty("basedir");
if (basedir == null) {
basedir = new File(".").getCanonicalPath();
}
// Read in camel configuration file and substitute in the correct port
File f = new File(basedir + "/src/test/resources/camel-scp.xml");
FileInputStream inputStream = new FileInputStream(f);
String content = IOUtils.toString(inputStream, "UTF-8");
inputStream.close();
content = content.replaceAll("portno", "" + port);
File f2 = new File(basedir + "/target/test-classes/camel-scp.xml");
FileOutputStream outputStream = new FileOutputStream(f2);
IOUtils.write(content, outputStream, "UTF-8");
outputStream.close();
sshServer = SshServer.setUpDefaultServer();
sshServer.setPort(port);
// Generate a key
sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(Paths.get("target/generatedkey.pem")));
sshServer.setCommandFactory(new ScpCommandFactory());
sshServer.setPasswordAuthenticator(new CamelPasswordAuthenticator());
sshServer.start();
setupKnownHosts(port);
// Create "storage" directory (delete it first if it exists)
File storageDirectory = new File(basedir + "/target/storage");
if (storageDirectory.exists()) {
storageDirectory.delete();
}
storageDirectory.mkdir();
}
use of org.apache.sshd.server.scp.ScpCommandFactory in project wildfly-camel by wildfly-extras.
the class EmbeddedSSHServer method setupSftp.
public void setupSftp() {
this.sshServer.setCommandFactory(new ScpCommandFactory());
this.sshServer.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
}
Aggregations