public Map<String, Object> getProperties() { return Collections.unmodifiableMap(sshd.getProperties()); }
server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(idleTimeout)); server.getProperties().put(SshServer.NIO_WORKERS, Integer.toString(nioWorkers)); server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(idleTimeout)); server.getProperties().put(SshServer.NIO_WORKERS, Integer.toString(nioWorkers)); server.getProperties().put(SshServer.WELCOME_BANNER, welcomeBanner);
public void startServer(Integer timeout) throws Exception { if (server != null) { throw failure("Server already started"); } server = SshServer.setUpDefaultServer(); if (timeout != null) { server.getProperties().put(FactoryManager.AUTH_TIMEOUT, timeout.toString()); } server.setPort(5000); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath())); server.setPasswordAuthenticator((username, password, sess) -> authenticator.authenticate(username, password, sess)); server.setShellFactory(new EchoShellFactory()); server.setServiceFactories(Arrays.asList(ServerConnectionServiceFactory.INSTANCE, AsyncUserAuthServiceFactory.INSTANCE)); server.start(); }
public void startServer(Integer timeout) throws Exception { if (server != null) { throw failure("Server already started"); } server = SshServer.setUpDefaultServer(); if (timeout != null) { server.getProperties().put(FactoryManager.AUTH_TIMEOUT, timeout.toString()); } server.setPort(5000); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath())); server.setPasswordAuthenticator((username, password, sess) -> authenticator.authenticate(username, password, sess)); server.setShellFactory(new EchoShellFactory()); server.setServiceFactories(Arrays.asList(ServerConnectionServiceFactory.INSTANCE, AsyncUserAuthServiceFactory.INSTANCE)); server.start(); }
public void startServer(Integer timeout) throws Exception { if (server != null) { throw failure("Server already started"); } server = SshServer.setUpDefaultServer(); if (timeout != null) { server.getProperties().put(FactoryManager.AUTH_TIMEOUT, timeout.toString()); } server.setPort(5000); server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser").toPath())); server.setPasswordAuthenticator(new PasswordAuthenticator() { @Override public boolean authenticate(String username, String password, ServerSession session) throws PasswordChangeRequiredException { return authenticator.authenticate(username, password, session); } }); server.setShellFactory(new EchoShellFactory()); server.setServiceFactories(Arrays.asList(ServerConnectionServiceFactory.INSTANCE, AsyncUserAuthServiceFactory.INSTANCE)); server.start(); }
@Test public void testCheckTimeout() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); sshService.start(); assertTrue(sshService.isRunning()); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckTimeout() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService); sshService.start(); assertTrue(sshService.isRunning()); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, "", ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testWithWrongCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes126-cbc,aes124-ctr,aes192-cbc,aes192-ctr,aes255-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(5); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; String macs = "hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96, hmac-sha2-256, hmac-sha2-512"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, macs); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, "", ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckNullCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, null, null); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckNullCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, null, null); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testWithWrongCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes126-cbc,aes124-ctr,aes192-cbc,aes192-ctr,aes255-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(5); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyCiphers() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String macs = "hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96, hmac-sha2-256, hmac-sha2-512"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, "", macs); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyCiphers() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String macs = "hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96, hmac-sha2-256, hmac-sha2-512"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, "", macs); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckEmptyMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, ""); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }
@Test public void testCheckCiphersAndMacs() throws Exception { final GitSSHService sshService = new GitSSHService(); final File certDir = createTempDirectory(); String idleTimeout = "10000"; String ciphers = "aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr,arcfour128,arcfour256,blowfish-cbc,3des-cbc"; String macs = "hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96, hmac-sha2-256, hmac-sha2-512"; sshService.setup(certDir, null, idleTimeout, "RSA", mock(ReceivePackFactory.class), mock(JGitFileSystemProvider.RepositoryResolverImpl.class), executorService, ciphers, macs); sshService.start(); assertTrue(sshService.isRunning()); List<String> ciphersReaded = sshService.getSshServer().getCipherFactoriesNames(); List<String> macsReaded = sshService.getSshServer().getMacFactoriesNames(); assertThat(ciphersReaded).hasSize(7); checkCiphersName(ciphersReaded); assertThat(macsReaded).hasSize(6); checkMacsName(macsReaded); assertThat(sshService.getSshServer().getProperties().get(SshServer.IDLE_TIMEOUT)).isEqualTo(idleTimeout); sshService.stop(); assertFalse(sshService.isRunning()); }