Skip to content
Snippets Groups Projects
Commit 905d0263 authored by Or Cohen's avatar Or Cohen Committed by Pekka Enberg
Browse files

java: Remove sshd module


This is the old and obsolete sshd implementation.

Signed-off-by: default avatarOr Cohen <orc@fewbytes.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 5954a2e2
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
package com.cloudius.sshd;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import com.cloudius.cli.main.RhinoCLI;
public class RhinoCLICommand implements Command {
private Thread cliThread;
final Tty tty = new Tty();
public RhinoCLICommand(String cliJs) {
this.cliThread = new RhinoCLIThread();
}
class RhinoCLIThread extends Thread {
@Override
public void run() {
String[] args = {};
RhinoCLI.run(tty, false, args);
}
}
@Override
public void start(Environment env) {
cliThread.start();
}
@Override
public void setOutputStream(OutputStream out) {
tty.setOut(out);
}
@Override
public void setInputStream(InputStream in) {
tty.setIn(in);
}
@Override
public void setExitCallback(ExitCallback callback) {
}
@Override
public void setErrorStream(OutputStream err) {
tty.setErr(err);
}
@Override
public void destroy() {
cliThread.interrupt();
}
}
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
package com.cloudius.sshd;
import org.apache.sshd.common.Factory;
import org.apache.sshd.server.Command;
public class RhinoShellFactory implements Factory<Command> {
String cliJs;
public RhinoShellFactory(String cliJs) {
this.cliJs = cliJs;
}
@Override
public Command create() {
return new RhinoCLICommand(cliJs);
}
}
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
package com.cloudius.sshd;
import java.io.IOException;
import java.util.ArrayList;
import org.apache.sshd.SshServer;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.sftp.SftpSubsystem;
public class Server {
public static final String DEFAULT_PORT = "22";
public static final String DEFAULT_HOSTKEY = "/etc/hostkey.est";
public static final String DEFAULT_CONSOLE_CLI = "/console/cli.js";
public static final String SYSTEM_PREFIX = "com.cloudius.sshd.";
public static final String SYSTEM_PROP_PORT = SYSTEM_PREFIX + "port";
public static final String SYSTEM_PROP_HOSTKEY = SYSTEM_PREFIX + "hostkey";
public static final String SYSTEM_PROP_CONSOLE_CLI = SYSTEM_PREFIX
+ "console.cli";
public static void main(String[] args) throws IOException {
SshServer sshServer = SshServer.setUpDefaultServer();
sshServer.setPort(Integer.parseInt(System.getProperty(SYSTEM_PROP_PORT,
DEFAULT_PORT)));
sshServer.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(System
.getProperty(SYSTEM_PROP_HOSTKEY, DEFAULT_HOSTKEY)));
// Support SCP
sshServer.setCommandFactory(new ScpCommandFactory());
// Support SFTP subsystem
ArrayList<NamedFactory<Command>> subsystemFactoriesList = new ArrayList<NamedFactory<Command>>(
1);
subsystemFactoriesList.add(new SftpSubsystem.Factory());
sshServer.setSubsystemFactories(subsystemFactoriesList);
// Set shell factory to Rhino
sshServer.setShellFactory(new RhinoShellFactory(System.getProperty(
SYSTEM_PROP_CONSOLE_CLI, DEFAULT_CONSOLE_CLI)));
// Basic non-existend authentication
sshServer.setPasswordAuthenticator(new PasswordAuthenticator() {
@Override
public boolean authenticate(String arg0, String arg1,
ServerSession arg2) {
// TODO Implement authentication
return true;
}
});
sshServer.start();
}
}
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
package com.cloudius.sshd;
import com.cloudius.util.IStty;
public class Stty implements IStty {
@Override
public void reset() {
}
@Override
public void close() throws Exception {
}
@Override
public void raw() {
}
}
/*
* Copyright (C) 2013 Cloudius Systems, Ltd.
*
* This work is open source software, licensed under the terms of the
* BSD license as described in the LICENSE file in the top-level directory.
*/
package com.cloudius.sshd;
import java.io.InputStream;
import java.io.OutputStream;
import com.cloudius.cli.main.RhinoCLI;
public class Tty implements RhinoCLI.TTY {
InputStream in;
OutputStream out;
OutputStream err;
Stty stty = new Stty();
public InputStream getIn() {
return in;
}
public void setIn(InputStream in) {
this.in = in;
}
public OutputStream getOut() {
return out;
}
public void setOut(OutputStream out) {
this.out = out;
}
public OutputStream getErr() {
return err;
}
public void setErr(OutputStream err) {
this.err = err;
}
public Stty getStty() {
return stty;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment