Java Code Examples for org.apache.commons.net.ftp.FTPSClient#login()

The following examples show how to use org.apache.commons.net.ftp.FTPSClient#login() . 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: ConnectionStressTest.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    try {
        FTPSClient c = new FTPSClient();
        c.configure(ftpConfig);

        logger.debug("Trying to connect");
        c.connect("127.0.0.1", 2121);
        logger.debug("Connected");

        c.setSoTimeout(5000);

        if (!FTPReply.isPositiveCompletion(c.getReplyCode())) {
            logger.debug("Houston, we have a problem. D/C");
            c.disconnect();
            throw new Exception();
        }

        if (c.login("drftpd", "drftpd")) {
            logger.debug("Logged-in, now waiting 5 secs and kill the thread.");
            _sc.addSuccess();
            Thread.sleep(5000);
            c.disconnect();
        } else {
            logger.debug("Login failed, D/C!");
            throw new Exception();
        }
    } catch (Exception e) {
        logger.debug(e, e);
        _sc.addFailure();
    }

    logger.debug("exiting");
}
 
Example 2
Source File: ConnectionStressTest.java    From drftpd with GNU General Public License v2.0 5 votes vote down vote up
public void run() {
    try {
        FTPSClient c = new FTPSClient();
        c.configure(ftpConfig);

        logger.debug("Trying to connect");
        c.connect("127.0.0.1", 2121);
        logger.debug("Connected");

        c.setSoTimeout(5000);

        if (!FTPReply.isPositiveCompletion(c.getReplyCode())) {
            logger.debug("Houston, we have a problem. D/C");
            c.disconnect();
            throw new Exception();
        }

        if (c.login("drftpd", "drftpd")) {
            logger.debug("Logged-in, now waiting 5 secs and kill the thread.");
            _sc.addSuccess();
            Thread.sleep(5000);
            c.disconnect();
        } else {
            logger.debug("Login failed, D/C!");
            throw new Exception();
        }
    } catch (Exception e) {
        logger.debug(e, e);
        _sc.addFailure();
    }

    logger.debug("exiting");
}
 
Example 3
Source File: FTPUtils.java    From TranskribusCore with GNU General Public License v3.0 4 votes vote down vote up
public static void loginToFTP(FTPSClient ftp, String ftpUser, String ftpPw) throws IOException {
	if (!ftp.login(ftpUser, ftpPw)) {
		throw new IOException("Unable to login!");
	}
}
 
Example 4
Source File: FTPClientWrapper.java    From JPPF with Apache License 2.0 3 votes vote down vote up
/**
 * Open a secure ftp connection with the specified parameters.
 * @param host the host where the FTP server is running
 * @param port the secure FTP port.
 * @param user username to use.
 * @param password the user password.
 * @throws Exception if any error occurs.
 */
public void open(final String host, final int port, final String user, final String password) throws Exception {
  // create with implicit TLS
  ftpClient = new FTPSClient(true);
  ftpClient.connect(host, port);
  ftpClient.login(user, password);
}