Package org.apache.commons.net.ftp

Examples of org.apache.commons.net.ftp.FTPClient.login()


       
        // let's generate some stats
        FTPClient client1 = new FTPClient();
        client1.connect("localhost", getListenerPort());
       
        assertTrue(client1.login(ADMIN_USERNAME, ADMIN_PASSWORD));
        assertTrue(client1.makeDirectory("foo"));
        assertTrue(client1.makeDirectory("foo2"));
        assertTrue(client1.removeDirectory("foo2"));
        assertTrue(client1.storeFile(TEST_FILENAME, new ByteArrayInputStream(TESTDATA)));
        assertTrue(client1.storeFile(TEST_FILENAME, new ByteArrayInputStream(TESTDATA)));
View Full Code Here


        client1.disconnect();

        FTPClient client2 = new FTPClient();
        client2.connect("localhost", getListenerPort());

        assertTrue(client2.login(ANONYMOUS_USERNAME, ANONYMOUS_PASSWORD));
        // done setting up stats
       
        // send a command to verify that we are correctly logged in
        assertTrue(FTPReply.isPositiveCompletion(client2.noop()));
       
View Full Code Here

            assertTrue(client1.login(TESTUSER1_USERNAME, TESTUSER_PASSWORD));
            assertTrue(client2.login(TESTUSER1_USERNAME, TESTUSER_PASSWORD));
            assertTrue(client3.login(TESTUSER1_USERNAME, TESTUSER_PASSWORD));

            try {
                assertTrue(client4.login(TESTUSER1_USERNAME, TESTUSER_PASSWORD));
                assertEquals(421, client.getReplyCode());
                fail("Must throw FTPConnectionClosedException");
            } catch (FTPConnectionClosedException e) {
                // expected
            }
View Full Code Here

                {
                    throw new FileSystemException("vfs.provider.ftp/connect-rejected.error", hostname);
                }

                // Login
                if (!client.login(username, password))
                {
                    throw new FileSystemException("vfs.provider.ftp/login.error", new Object[]{hostname, username}, null);
                }

                // Set binary mode
View Full Code Here

        int reply = client.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply))
        {
            throw new IllegalArgumentException("cant connect: " + reply);
        }
        if (!client.login(user, pass))
        {
            throw new IllegalArgumentException("login failed");
        }
        client.enterLocalPassiveMode();
View Full Code Here

            }
            res.latencyEnd();
            int reply = ftp.getReplyCode();
            if (FTPReply.isPositiveCompletion(reply))
            {
                if (ftp.login( getUsername(), getPassword())){
                    if (binaryTransfer) {
                        ftp.setFileType(FTP.BINARY_FILE_TYPE);
                    }
                    ftp.enterLocalPassiveMode();// should probably come from the setup dialog
                    boolean ftpOK=false;
View Full Code Here

        + " " + usr + " " + pwd + " " + dir);
    String keyValueSeparator = conf.get(
        "mapred.textoutputformat.separator", "\t");
    FTPClient f = new FTPClient();
    f.connect(ip, Integer.parseInt(portno));
    f.login(usr, pwd);
    f.changeWorkingDirectory(dir);
    f.setFileType(FTP.BINARY_FILE_TYPE);

    boolean isCompressed = getCompressOutput(job);
    CompressionCodec codec = null;
View Full Code Here

        int reply = client.getReplyCode();
        if (!FTPReply.isPositiveCompletion(reply))
        {
            throw new IllegalArgumentException("cant connect: " + reply);
        }
        if (!client.login(user, pass))
        {
            throw new IllegalArgumentException("login failed");
        }
        client.enterLocalPassiveMode();
View Full Code Here

    int reply = client.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply)) {
      throw NetUtils.wrapException(host, port,
                   NetUtils.UNKNOWN_HOST, 0,
                   new ConnectException("Server response " + reply));
    } else if (client.login(user, password)) {
      client.setFileTransferMode(FTP.BLOCK_TRANSFER_MODE);
      client.setFileType(FTP.BINARY_FILE_TYPE);
      client.setBufferSize(DEFAULT_BUFFER_SIZE);
    } else {
      throw new IOException("Login failed on server - " + host + ", port - "
View Full Code Here

        String host = config.getHost();
        int port = config.getPort();
        LOG.debug("Connecting to host: " + host + " port: " + port);

        client.connect(host, port);
        client.login(config.getUsername(), config.getPassword());
        client.setFileType(config.isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
        return client;
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.