net.schmizz.sshj.userauth.UserAuthException Java Examples
The following examples show how to use
net.schmizz.sshj.userauth.UserAuthException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SSHChannel.java From TeamSpeak-3-Java-API with MIT License | 6 votes |
SSHChannel(TS3Config config) throws IOException { if (!config.hasLoginCredentials()) { throw new TS3ConnectionFailedException("Anonymous queries are not supported when using SSH.\n" + "\t\tYou must specify a query username and password using TS3Config#setLoginCredentials."); } try { client = new SSHClient(); File knownHostsFile = new File(OpenSSHKnownHosts.detectSSHDir(), KNOWN_HOSTS_FILE_NAME); client.addHostKeyVerifier(new AutoAddKnownHosts(knownHostsFile)); client.setConnectTimeout(config.getCommandTimeout()); client.setTimeout(config.getCommandTimeout()); client.setRemoteCharset(StandardCharsets.UTF_8); client.connect(config.getHost(), config.getQueryPort()); client.authPassword(config.getUsername(), config.getPassword()); session = client.startSession(); session.startShell(); } catch (UserAuthException uae) { close(); throw new TS3ConnectionFailedException("Invalid query username or password"); } catch (IOException ioe) { close(); throw ioe; } }
Example #2
Source File: AwsYcloudHybridCloudTest.java From cloudbreak with Apache License 2.0 | 5 votes |
private void testShhAuthenticationFailure(String username, String host) throws IOException { SSHClient client = null; try { client = getSshClient(host); client.authPassword(username, MOCK_UMS_PASSWORD_INVALID); fail("SSH authentication passed with invalid password."); } catch (UserAuthException ex) { //Expected } if (client != null) { client.close(); } }
Example #3
Source File: ConnectAndAuthTest.java From rpicheck with MIT License | 5 votes |
@Test(expected = RaspiQueryException.class) public void connect_auth_failure() throws RaspiQueryException, UserAuthException, TransportException { Mockito.doThrow(UserAuthException.class).when(sshClient) .authPassword(Mockito.anyString(), Mockito.anyString()); raspiQuery.connect("wrong_pw"); }
Example #4
Source File: AwsYcloudHybridCloudTest.java From cloudbreak with Apache License 2.0 | 4 votes |
private void testShhAuthenticationSuccessfull(String username, String host) throws IOException, UserAuthException { SSHClient client = getSshClient(host); client.authPassword(username, MOCK_UMS_PASSWORD); client.close(); }