session.addPublicKeyIdentity(pair); session.auth().verify(10000L);
@Override public void connect(String hostname, String username, String password, Long port, Long timeout) throws IOException { if (port == null) port = 22l; if (timeout == null) timeout = 10000l; if (sftp != null) return; ClientSession session = client.connect(username, hostname, port.intValue()).verify(timeout.intValue()).getSession(); session.addPasswordIdentity(password); session.auth().verify(timeout.intValue()); sftp = session.createSftpClient(); }
private static AuthFuture authPassword(ClientSession s, String user, String pswd) throws IOException { s.setUsername(user); s.addPasswordIdentity(pswd); return s.auth(); }
private static AuthFuture authPassword(ClientSession s, String user, String pswd) throws IOException { s.setUsername(user); s.addPasswordIdentity(pswd); return s.auth(); }
private static AuthFuture authPassword(ClientSession s, String user, String pswd) throws IOException { s.setUsername(user); s.addPasswordIdentity(pswd); return s.auth(); }
private static AuthFuture authPublicKey(ClientSession s, String user, KeyPair pair) throws IOException { s.setUsername(user); s.addPublicKeyIdentity(pair); return s.auth(); }
private static AuthFuture authPublicKey(ClientSession s, String user, KeyPair pair) throws IOException { s.setUsername(user); s.addPublicKeyIdentity(pair); return s.auth(); }
private static AuthFuture authPublicKey(ClientSession s, String user, KeyPair pair) throws IOException { s.setUsername(user); s.addPublicKeyIdentity(pair); return s.auth(); }
private void testKexFutureExceptionPropagation(String failureType, AtomicBoolean successFlag, SshClient client) throws Exception { try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); successFlag.set(false); KeyExchangeFuture kexFuture = session.switchToNoneCipher(); assertTrue(failureType + ": failed to complete KEX on time", kexFuture.await(7L, TimeUnit.SECONDS)); assertNotNull(failureType + ": unexpected success", kexFuture.getException()); } }
private void testKexFutureExceptionPropagation(String failureType, AtomicBoolean successFlag, SshClient client) throws Exception { try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); successFlag.set(false); KeyExchangeFuture kexFuture = session.switchToNoneCipher(); assertTrue(failureType + ": failed to complete KEX on time", kexFuture.await(7L, TimeUnit.SECONDS)); assertNotNull(failureType + ": unexpected success", kexFuture.getException()); } }
private void testKexFutureExceptionPropagation(String failureType, AtomicBoolean successFlag, SshClient client) throws Exception { try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); successFlag.set(false); KeyExchangeFuture kexFuture = session.switchToNoneCipher(); assertTrue(failureType + ": failed to complete KEX on time", kexFuture.await(7L, TimeUnit.SECONDS)); assertNotNull(failureType + ": unexpected success", kexFuture.getException()); } }
@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); } } }
private ClientSession createTestClientSession(SshServer server) throws Exception { ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, server.getPort()).verify(7L, TimeUnit.SECONDS).getSession(); try { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); ClientSession returnValue = session; session = null; // avoid 'finally' close return returnValue; } finally { if (session != null) { session.close(); } } }
private ClientSession createTestClientSession(SshServer server) throws Exception { ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, server.getPort()).verify(7L, TimeUnit.SECONDS).getSession(); try { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); ClientSession returnValue = session; session = null; // avoid 'finally' close return returnValue; } finally { if (session != null) { session.close(); } } }
private ClientSession createTestClientSession(SshServer server) throws Exception { ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, server.getPort()).verify(7L, TimeUnit.SECONDS).getSession(); try { session.addPasswordIdentity(getCurrentTestName()); session.auth().verify(5L, TimeUnit.SECONDS); ClientSession returnValue = session; session = null; // avoid 'finally' close return returnValue; } finally { if (session != null) { session.close(); } } }
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; } }