Examples of SshServer


Examples of com.consol.citrus.ssh.server.SshServer

        Map<String, SshServer> servers = beanDefinitionContext.getBeansOfType(SshServer.class);

        Assert.assertEquals(servers.size(), 3);

        // 1st server
        SshServer server = servers.get("sshServer1");
        Assert.assertEquals(server.getName(), "sshServer1");
        Assert.assertEquals(server.getPort(), 22);
        Assert.assertFalse(server.isAutoStart());
        Assert.assertNull(server.getAllowedKeyPath());
        Assert.assertNull(server.getHostKeyPath());
        Assert.assertNull(server.getUser());
        Assert.assertNull(server.getPassword());
        Assert.assertTrue(server.getEndpointAdapter() instanceof ChannelEndpointAdapter);
        Assert.assertNull(server.getActor());

        // 2nd server
        server = servers.get("sshServer2");
        Assert.assertEquals(server.getName(), "sshServer2");
        Assert.assertEquals(server.getPort(), 10022);
        Assert.assertFalse(server.isAutoStart());
        Assert.assertEquals(server.getAllowedKeyPath(), "classpath:com/consol/citrus/ssh/citrus_pub.pem");
        Assert.assertEquals(server.getHostKeyPath(), "classpath:com/consol/citrus/ssh/citrus.pem");
        Assert.assertEquals(server.getUser(), "foo");
        Assert.assertEquals(server.getPassword(), "bar");
        Assert.assertTrue(server.getEndpointAdapter() instanceof ChannelEndpointAdapter);
        Assert.assertNull(server.getActor());

        // 3rd server
        server = servers.get("sshServer3");
        Assert.assertEquals(server.getName(), "sshServer3");
        Assert.assertEquals(server.getPort(), 22);
        Assert.assertFalse(server.isAutoStart());
        Assert.assertNull(server.getAllowedKeyPath());
        Assert.assertNull(server.getHostKeyPath());
        Assert.assertNull(server.getUser());
        Assert.assertNull(server.getPassword());
        Assert.assertEquals(server.getEndpointAdapter(), beanDefinitionContext.getBean("sshServerAdapter"));
        Assert.assertNull(server.getActor());
    }
View Full Code Here

Examples of com.sshtools.daemon.SshServer

    configureServer ();
  }

  private void start () throws IOException {

    SshServer server = new SshServer() {

      @Override
      public void configureServices (ConnectionProtocol connection) throws IOException {
        connection.addChannelFactory(SessionChannelFactory.SESSION_CHANNEL,
          new SessionChannelFactory());

        if (ConfigurationLoader.isConfigurationAvailable(ServerConfiguration.class)) {
          if ((ConfigurationLoader
            .getConfiguration(com.sshtools.daemon.configuration.ServerConfiguration.class)).getAllowTcpForwarding()) {
//            ForwardingServer forwarding =
            new ForwardingServer(connection);
          }
        }
      }

      @Override
      public void shutdown (String msg) {
        // Disconnect all sessions
      }

      @Override
      protected boolean isAcceptConnectionFrom(Socket socket) {
        return true;
      }

    };

    server.startServer();
  }
View Full Code Here

Examples of org.apache.sshd.SshServer

        c.put(new ByteArrayInputStream(data.getBytes()), path);
        c.disconnect();
    }

    public static void main(String[] args) throws Exception {
        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.setPort(8001);
        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
        sshd.setShellFactory(new EchoShellFactory());
        sshd.setCommandFactory(new ScpCommandFactory());
        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
        sshd.start();
        Thread.sleep(100000);
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

        //
        // TODO: the GitpgmCommandFactory is kept in the test tree
        // TODO: because it's quite limited for now
        //

        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.setPort(8001);
        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
        sshd.setShellFactory(new EchoShellFactory());
        sshd.setCommandFactory(new GitPgmCommandFactory("target/git/pgm"));
        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
        sshd.start();

        File serverDir = new File("target/git/pgm");
        Utils.deleteRecursive(serverDir);

        File repo = new File(serverDir, "test");

        SshClient client = SshClient.setUpDefaultClient();
        client.start();

        ClientSession session = client.connect("sshd", "localhost", 8001).await().getSession();
        session.addPasswordIdentity("sshd");
        session.auth().verify();

        Git.init().setDirectory(repo).call();
        Git git = Git.open(repo);
        git.commit().setMessage("First Commit").setCommitter("sshd", "sshd@apache.org").call();

        new File("target/git/pgm/test/readme.txt").createNewFile();
        execute(session, "git --git-dir test add readme.txt");

        execute(session, "git --git-dir test commit -m \"readme\"");

        client.stop();
        sshd.stop();
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

*/
public class GitPackCommandTest {

    @Test
    public void testGitPack() throws Exception {
        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.setPort(8001);
        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
        sshd.setShellFactory(new EchoShellFactory());
        sshd.setCommandFactory(new GitPackCommandFactory("target/git/server"));
        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
        sshd.start();

        File serverDir = new File("target/git/server/test.git");
        Utils.deleteRecursive(serverDir);
        Git.init().setBare(true).setDirectory(serverDir).call();

        JSch.setConfig("StrictHostKeyChecking", "no");
        CredentialsProvider.setDefault(new UsernamePasswordCredentialsProvider("sshd", "sshd"));
        GitSshdSessionFactory.setInstance(new GitSshdSessionFactory());

        File dir = new File("target/git/local/test.git");
        Utils.deleteRecursive(dir);
        Git.cloneRepository()
                .setURI("ssh://sshd@localhost:8001/test.git")
                .setDirectory(dir)
                .call();

        Git git = Git.open(dir);
        git.commit().setMessage("First Commit").setCommitter("sshd", "sshd@apache.org").call();
        git.push().call();

        new File("target/git/local/test.git/readme.txt").createNewFile();
        git.add().addFilepattern("readme.txt").call();
        git.commit().setMessage("readme").setCommitter("sshd", "sshd@apache.org").call();
        git.push().call();

        git.pull().setRebase(true).call();

        sshd.stop();
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

    public void setSshServerId(String sshServerId) {
        this.sshServerId = sshServerId;
    }

    protected Object doExecute() throws Exception {
        SshServer server = (SshServer) container.getComponentInstance(sshServerId);

        log.debug("Created server: {}", server);

        // port number
        server.setPort(port);

        // idle timeout
        server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());

        // starting the SSHd server
        server.start();

        System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms)");

        if (!background) {
            synchronized (this) {
                log.debug("Waiting for server to shutdown");

                wait();
            }

            server.stop();
        }

        return null;
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

    public void setSshServerId(String sshServerId) {
        this.sshServerId = sshServerId;
    }

    protected Object doExecute() throws Exception {
        SshServer server = (SshServer) container.getComponentInstance(sshServerId);

        log.debug("Created server: {}", server);

        // port number
        server.setPort(port);

        // idle timeout
        server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());

        // starting the SSHd server
        server.start();

        System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms)");

        if (!background) {
            synchronized (this) {
                log.debug("Waiting for server to shutdown");

                wait();
            }

            server.stop();
        }

        return null;
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

    public void setSshServerId(String sshServerId) {
        this.sshServerId = sshServerId;
    }

    protected Object doExecute() throws Exception {
        SshServer server = (SshServer) container.getComponentInstance(sshServerId);

        log.debug("Created server: {}", server);

        // port number
        server.setPort(port);

        // idle timeout
        server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());

        // welcome banner
        if (welcomeBanner != null) {
            server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
        }

        // starting the SSHd server
        server.start();

        System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms)");

        if (!background) {
            synchronized (this) {
                log.debug("Waiting for server to shutdown");

                wait();
            }

            server.stop();
        }

        return null;
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

    public void setSshServerId(String sshServerId) {
        this.sshServerId = sshServerId;
    }

    protected Object doExecute() throws Exception {
        SshServer server = (SshServer) container.getComponentInstance(sshServerId);

        log.debug("Created server: {}", server);

        server.setPort(port);

        server.start();

        System.out.println("SSH server listening on port " + port);

        if (!background) {
            synchronized (this) {
                log.debug("Waiting for server to shutdown");

                wait();
            }

            server.stop();
        }

        return null;
    }
View Full Code Here

Examples of org.apache.sshd.SshServer

    public void testGit() {

    }

    public static void main(String[] args) throws Exception {
        SshServer sshd = SshServer.setUpDefaultServer();
        sshd.getProperties().put(SshServer.IDLE_TIMEOUT, "10000");
        sshd.setPort(8001);
        sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
        sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
        sshd.setShellFactory(new EchoShellFactory());
//        sshd.setCommandFactory(new ScpCommandFactory());
        sshd.setCommandFactory(new CommandFactory() {
            public Command createCommand(String command) {
                if (command.startsWith("git-")) {
                    return new GitCommand(command.substring("git-".length()));
                } else {
                    return new UnknownCommand(command);
                }
            }
        });
        sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
        sshd.start();
        Thread.sleep(100000);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.