try(SshClient client = SshClient.setUpDefaultClient()) {
public SshFtpClient() { client = SshClient.setUpDefaultClient(); client.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; }
/** * Create the client for testing using org.mockito.Mockito. * * @return client. */ SshClient createSshClient() { SshClient sshClient = SshClient.setUpDefaultClient(); /* * FIXME: We need to enforce only RSA signatures, because all our code around fingerprints assumes only RSA * public keys. This limitation can be removed when we will save all available host public keys into database * and perform host key verification by comparing received key with keys in our database. */ sshClient.setSignatureFactories(Arrays.<NamedFactory<Signature>> asList( BuiltinSignatures.rsa)); return sshClient; }
/** * 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); }
@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(); }
@Test public void testConnectTimeout() throws Exception { SSHClient client = spy(this.client); SshClient ssh = spy(SshClient.setUpDefaultClient()); ConnectFuture future = mock(ConnectFuture.class); doReturn(ssh).when(client).createSshClient(); doReturn(future).when(ssh).connect(any(), any(), anyInt()); when(future.await(anyLong())).thenReturn(false); assertThrows(TimeLimitExceededException.class, client::connect); }
try { final Console console = System.console(); client = SshClient.setUpDefaultClient(); setupAgent(user, keyFile, client);
try { final Console console = System.console(); client = SshClient.setUpDefaultClient(); setupAgent(user, keyFile, client);
try { final Console console = System.console(); client = SshClient.setUpDefaultClient(); setupAgent(user, keyFile, client);
try { final Console console = System.console(); client = SshClient.setUpDefaultClient(); setupAgent(user, keyFile, client);
@Test public void testPasswordTimeout() throws Exception { SSHClient client = spy(this.client); SshClient ssh = spy(SshClient.setUpDefaultClient()); ConnectFuture future = mock(ConnectFuture.class); ClientSession session = mock(ClientSession.class); doReturn(ssh).when(client).createSshClient(); doReturn(future).when(ssh).connect(any(), any(), anyInt()); when(future.await(anyLong())).thenReturn(true); when(future.getSession()).thenReturn(session); AuthFuture authFuture = mock(AuthFuture.class); when(authFuture.await(anyLong())).thenReturn(false); when(session.auth()).thenReturn(authFuture); assertThrows(TimeLimitExceededException.class, () -> { client.connect(); client.authenticate(); }); } }
public static SshClient setupTestClient(Class<?> anchor) { SshClient client = SshClient.setUpDefaultClient(); client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE); client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY); client.setKeyPairProvider(KeyPairProvider.EMPTY_KEYPAIR_PROVIDER); return client; }
public static SshClient setupTestClient(Class<?> anchor) { SshClient client = SshClient.setUpDefaultClient(); client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE); client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY); client.setKeyPairProvider(KeyPairProvider.EMPTY_KEYPAIR_PROVIDER); return client; }
public static SshClient setupTestClient(Class<?> anchor) { SshClient client = SshClient.setUpDefaultClient(); client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE); client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY); client.setKeyPairProvider(KeyPairProvider.EMPTY_KEYPAIR_PROVIDER); return client; }
SshClient client = SshClient.setUpDefaultClient(); if (this.session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME) != null) { client.setAgentFactory(KarafAgentFactory.getInstance());
SshClient client = SshClient.setUpDefaultClient(); if (this.session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME) != null) { client.setAgentFactory(KarafAgentFactory.getInstance());