/** * Authenticate the bound connection using the supplied credentials. * * @return For an {@link #getAuthenticationMode()} of {@link Mode#BEFORE_CONNECT} the return value is * always {@code true} otherwise the return value is {@code true} if and only if authentication was * successful. */ public final boolean authenticate(TaskListener listener) { setListener(listener); return authenticate(); }
private Session createSession(final PrintStream logger) throws JSchException, IOException, InterruptedException { final StandardUsernameCredentials user = lookupCredentialsById(credentialId); if (user == null) { String message = "Credentials with id '" + credentialId + "', no longer exist!"; logger.println(message); throw new InterruptedException(message); } final JSchConnector connector = new JSchConnector(user.getUsername(), getResolvedHostname(), port); final SSHAuthenticator<JSchConnector, StandardUsernameCredentials> authenticator = SSHAuthenticator .newInstance(connector, user); authenticator.authenticate(new StreamTaskListener(logger, Charset.defaultCharset())); final Session session = connector.getSession(); session.setServerAliveInterval(serverAliveInterval); final Properties config = new Properties(); //TODO put this as configuration option instead of ignoring by default config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(timeout); return session; }
throw new AbortException("Cannot find SSH User credentials with id: " + credentialsId); if (SSHAuthenticator.newInstance(connection, credentials).authenticate(listener) && connection.isAuthenticationComplete()) { logger.println(Messages.SSHLauncher_AuthenticationSuccessful(getTimestamp()));
throw new AbortException("Cannot find SSH User credentials with id: " + credentialsId); if (SSHAuthenticator.newInstance(connection, credentials).authenticate(listener) && connection.isAuthenticationComplete()) { logger.println(Messages.SSHLauncher_AuthenticationSuccessful(getTimestamp()));
&& smart.get(uri, item) && SSHAuthenticator.newInstance(con, item.getValue(), uri.getUser()) .authenticate(smart.listener); } else if (credentialsProvider instanceof CredentialsProviderImpl) { CredentialsProviderImpl sshcp = (CredentialsProviderImpl) credentialsProvider; authenticated = SSHAuthenticator.newInstance(con, sshcp.cred).authenticate(sshcp.listener); } else { authenticated = false;