use of org.apache.sshd.common.file.FileSystemFactory in project AmazeFileManager by TeamAmaze.
the class AbstractSftpServerTest method createSshServer.
protected final int createSshServer(FileSystemFactory fileSystemFactory, int startPort) throws IOException {
server = SshServer.setUpDefaultServer();
server.setFileSystemFactory(fileSystemFactory);
server.setPublickeyAuthenticator(AcceptAllPublickeyAuthenticator.INSTANCE);
server.setHost("127.0.0.1");
server.setKeyPairProvider(hostKeyProvider);
server.setCommandFactory(new ScpCommandFactory());
server.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
server.setPasswordAuthenticator(((username, password, session) -> username.equals("testuser") && password.equals("testpassword")));
try {
server.setPort(startPort);
server.start();
return startPort;
} catch (BindException ifPortIsUnavailable) {
return createSshServer(fileSystemFactory, startPort + 1);
}
}
Aggregations