/** * @deprecated Use {@link #newInstance(Object, StandardUsernameCredentials)} instead. */ @Deprecated public static SSHAuthenticator<Object, StandardUsernameCredentials> newInstance(Object connection, SSHUser user) throws InterruptedException, IOException { return newInstance(connection, (StandardUsernameCredentials) user, null); }
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; }
/** * Creates an authenticator that may be able to authenticate the supplied connection with the supplied user. * * @param connection the connection to authenticate on. * @param user the user to authenticate with. * @param <C> the type of connection. * @param <U> the type of user. * @return a {@link SSHAuthenticator} that may or may not be able to successfully authenticate. */ @NonNull public static <C, U extends StandardUsernameCredentials> SSHAuthenticator<C, U> newInstance(@NonNull C connection, @NonNull U user) throws InterruptedException, IOException { return newInstance(connection, user, null); }
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()));
authenticated = smart.supports(item) && 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;