Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cnc;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import org.apache.sshd.server.Environment;
- import org.apache.sshd.server.ExitCallback;
- import org.apache.sshd.server.channel.ChannelSession;
- import org.apache.sshd.server.command.Command;
- public class CNCCommands implements Command, Runnable{
- public CNCCommands() {
- super();
- }
- private InputStream in;
- private OutputStream out, errorStream;
- private ExitCallback callback;
- private String cmd = "cmd";
- @Override
- public void setInputStream(InputStream in) {
- this.in = in;
- }
- @Override
- public void setOutputStream(OutputStream out) {
- this.out = out;
- }
- @Override
- public void setErrorStream(OutputStream err) {
- this.errorStream = err;
- }
- @Override
- public void setExitCallback(ExitCallback callback) {
- this.callback = callback;
- }
- @Override
- public void start(ChannelSession channel, Environment env) throws IOException {
- // TODO Auto-generated method stub
- }
- @Override
- public void destroy(ChannelSession channel) throws Exception {
- // TODO Auto-generated method stub
- }
- @Override
- public void run() {
- while(!cmd.equalsIgnoreCase("exit")) {
- try {
- readCommand(in);
- handleCommand(cmd, out);
- } catch (Exception e) {
- writeError(errorStream, e);
- callback.onExit(-1, e.getMessage());
- return;
- }
- callback.onExit(0);
- }
- }
- private void writeError(OutputStream error, Exception e) {
- // TODO Auto-generated method stub
- }
- private void handleCommand(String commmandReceived, OutputStream outHandler) {
- // TODO Auto-generated method stub
- }
- private void readCommand(InputStream receivedCmd) throws IOException {
- String tmp = receivedCmd.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement