client.start();
public void open() throws IOException { start(); }
public void open() throws IOException { start(); }
public SftpFileSystemProvider(SshClient client, SftpClientFactory factory, SftpVersionSelector selector) { this.log = LoggerFactory.getLogger(getClass()); this.factory = factory; this.selector = selector; if (client == null) { // TODO: make this configurable using system properties client = SshClient.setUpDefaultClient(); client.start(); } this.client = client; }
public SshFtpClient() { client = SshClient.setUpDefaultClient(); client.start(); }
@Override protected void doStart() throws Exception { client = SshClient.setUpDefaultClient(); client.start(); super.doStart(); }
@Override protected void doStart() throws Exception { client = SshClient.setUpDefaultClient(); client.start(); super.doStart(); }
/** * Setup a default client, starts it and then wraps it as a {@link SimpleClient} * * @return The {@link SimpleClient} wrapper. <B>Note:</B> when the wrapper * is closed the client is also stopped * @see #setUpDefaultClient() * @see #wrapAsSimpleClient(SshClient) */ public static SimpleClient setUpDefaultSimpleClient() { SshClient client = setUpDefaultClient(); client.start(); return wrapAsSimpleClient(client); }
/** * Setup a default client, starts it and then wraps it as a {@link SimpleClient} * * @return The {@link SimpleClient} wrapper. <B>Note:</B> when the wrapper * is closed the client is also stopped * @see #setUpDefaultClient() * @see #wrapAsSimpleClient(SshClient) */ public static SimpleClient setUpDefaultSimpleClient() { SshClient client = setUpDefaultClient(); client.start(); return wrapAsSimpleClient(client); }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testAuthenticationTimeout() throws Exception { final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L); PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout); sshd.start(); client.start(); try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) { Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout); assertTrue("Session should be closed: " + res, res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH))); } finally { client.stop(); } }
@Test public void testIdleClient() throws Exception { SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll(EnumSet.of(ClientChannelEvent.CLOSED))); } } finally { client.stop(); } }
@Test public void testIdleClient() throws Exception { SshClient client = setupTestClient(); client.start(); try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); try (ClientChannel channel = session.createChannel(Channel.CHANNEL_SHELL)) { Collection<ClientChannelEvent> result = channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), WAIT); assertTrue("Wrong channel state: " + result, result.containsAll(EnumSet.of(ClientChannelEvent.CLOSED))); } } finally { client.stop(); } }
@Test public void testWrongPassword() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (ClientSession s = client.connect("user", TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { s.addPasswordIdentity("bad password"); assertAuthenticationResult(getCurrentTestName(), s.auth(), false); } } }
@Test public void testWrongPassword() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (ClientSession s = client.connect("user", TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { s.addPasswordIdentity("bad password"); assertAuthenticationResult(getCurrentTestName(), s.auth(), false); } } }
@Test public void testWrongPassword() throws Exception { try (SshClient client = setupTestClient()) { client.start(); try (ClientSession s = client.connect("user", TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { s.addPasswordIdentity("bad password"); assertAuthenticationResult(getCurrentTestName(), s.auth(), false); } } }
protected ClientSession createNativeSession() throws Exception { client = setupTestClient(); PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 2048); PropertyResolverUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 256); client.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE); client.start(); ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshPort).verify(7L, TimeUnit.SECONDS).getSession(); session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); return session; } }
protected ClientSession createNativeSession() throws Exception { client = setupTestClient(); PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 2048); PropertyResolverUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 256); client.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE); client.start(); ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshPort).verify(7L, TimeUnit.SECONDS).getSession(); session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); return session; } }
protected ClientSession createNativeSession() throws Exception { client = setupTestClient(); PropertyResolverUtils.updateProperty(client, FactoryManager.WINDOW_SIZE, 2048); PropertyResolverUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 256); client.setTcpipForwardingFilter(AcceptAllForwardingFilter.INSTANCE); client.start(); ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshPort).verify(7L, TimeUnit.SECONDS).getSession(); session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(11L, TimeUnit.SECONDS); return session; } }