public synchronized Session getSession() { if (!hasSession()) { try { session = jsch.getSession(username, host, port); } catch (JSchException e) { throw new SSHAuthenticatorException(e); } } return session; }
public synchronized Session getSession() { if (!hasSession()) { try { session = jsch.getSession(username, host, port); } catch (JSchException e) { throw new SSHAuthenticatorException(e); } } return session; }
/** * {@inheritDoc} */ @Override protected boolean doAuthenticate() { try { final SSHUserPrivateKey user = getUser(); final Secret userPassphrase = user.getPassphrase(); final String passphrase = userPassphrase == null ? null : userPassphrase.getPlainText(); byte[] passphraseBytes = passphrase == null ? null : passphrase.getBytes("UTF-8"); for (String privateKey : getPrivateKeys(user)) { getConnection().getJSch().addIdentity(getUsername(), privateKey.getBytes("UTF-8"), null, passphraseBytes); } return true; } catch (JSchException e) { e.printStackTrace(getListener().error("Failed to authenticate with public key")); return false; } catch (UnsupportedEncodingException e) { throw new SSHAuthenticatorException(e); } }
/** * {@inheritDoc} */ @Override protected boolean doAuthenticate() { try { final SSHUserPrivateKey user = getUser(); final Secret userPassphrase = user.getPassphrase(); final String passphrase = userPassphrase == null ? null : userPassphrase.getPlainText(); byte[] passphraseBytes = passphrase == null ? null : passphrase.getBytes("UTF-8"); for (String privateKey : getPrivateKeys(user)) { getConnection().getJSch().addIdentity(getUsername(), privateKey.getBytes("UTF-8"), null, passphraseBytes); } return true; } catch (JSchException e) { e.printStackTrace(getListener().error("Failed to authenticate with public key")); return false; } catch (UnsupportedEncodingException e) { throw new SSHAuthenticatorException(e); } }