Package org.apache.ftpserver

Examples of org.apache.ftpserver.FtpServerFactory


* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class EmbeddingFtpServer {

    public static void main(String[] args) throws Exception {
        FtpServerFactory serverFactory = new FtpServerFactory();
       
        ListenerFactory factory = new ListenerFactory();
       
        // set the port of the listener
        factory.setPort(2221);

        // define SSL configuration
        SslConfigurationFactory ssl = new SslConfigurationFactory();
        ssl.setKeystoreFile(new File("src/test/resources/ftpserver.jks"));
        ssl.setKeystorePassword("password");

        // set the SSL configuration for the listener
        factory.setSslConfiguration(ssl.createSslConfiguration());
        factory.setImplicitSsl(true);

        // replace the default listener
        serverFactory.addListener("default", factory.createListener());
       
        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File("myusers.properties"));
       
        serverFactory.setUserManager(userManagerFactory.createUserManager());
       
        // start the server
        FtpServer server = serverFactory.createServer();
       
        server.start();
    }
View Full Code Here


        }
       
    }
    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        ListenerFactory listenerFactory = new ListenerFactory(server.getListener("default"));
       
        DataConnectionConfigurationFactory dccFactory = new DataConnectionConfigurationFactory();

        dccFactory.setPassiveExternalAddress("127.0.0.1");

        listenerFactory.setDataConnectionConfiguration(dccFactory.createDataConnectionConfiguration());

        server.addListener("default", listenerFactory.createListener());
        CommandFactoryFactory cmFact = new CommandFactoryFactory();
        cmFact.setUseDefaultCommands(true);
        cmFact.addCommand("PASV", new PASVTest());
        server.setCommandFactory(cmFact.createCommandFactory());
        return server;
    }
View Full Code Here

   
    private static final File TEST_FILE = new File(ROOT_DIR, TEST_FILENAME);

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory serverFactory = super.createServer();
       
        // set a really short timeout
        ListenerFactory listenerFactory = new ListenerFactory(serverFactory.getListener("default"));
        listenerFactory.setIdleTimeout(1);
       
        serverFactory.addListener("default", listenerFactory.createListener());
       
        return serverFactory;
    }
View Full Code Here

public class DefaultFtpServerTest extends TestCase {

    public void testFailStartingSecondListener() throws Exception {
        // FTPSERVER-197
       
        FtpServerFactory serverFactory = new FtpServerFactory();
       
        ListenerFactory listenerFactory = new ListenerFactory();
        listenerFactory.setPort(0);
       
        // let's create two listeners on the same port, second should not start
    
        Listener defaultListener = listenerFactory.createListener();
        Listener secondListener = listenerFactory.createListener();
       
       
        serverFactory.addListener("default", defaultListener);
        serverFactory.addListener("second", secondListener);
       
        FtpServer server = serverFactory.createServer();
       
        try {
            server.start();
           
            // Windows seems to allow for both listeners to bind on the same port...
View Full Code Here

        initServer();
    }

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        Map<String, Ftplet> ftplets = new LinkedHashMap<String, Ftplet>();
        ftplets.put("f1", new MockFtplet());
        server.setFtplets(ftplets);
       
        return server;
    }
View Full Code Here

    }

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        Map<String, Ftplet> ftplets = new HashMap<String, Ftplet>();
        ftplets.put("f1", new MockFtplet());
       
        server.setFtplets(ftplets);
       
        return server;
    }
View Full Code Here

*/
public class PasvAddressWithHostnameTest extends ClientTestTemplate {

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        ListenerFactory listenerFactory = new ListenerFactory(server.getListener("default"));
       
        DataConnectionConfigurationFactory dccFactory = new DataConnectionConfigurationFactory();

        dccFactory.setPassiveExternalAddress("127.0.0.1");

        listenerFactory.setDataConnectionConfiguration(dccFactory.createDataConnectionConfiguration());

        server.addListener("default", listenerFactory.createListener());

        return server;
    }
View Full Code Here

    private String passiveAddress;

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        ListenerFactory listenerFactory = new ListenerFactory(server.getListener("default"));
       
        DataConnectionConfigurationFactory dccFactory = new DataConnectionConfigurationFactory();
       
        passiveAddress = TestUtil.findNonLocalhostIp().getHostAddress();
        dccFactory.setPassiveAddress(passiveAddress);
        dccFactory.setPassivePorts("12347");
        DataConnectionConfiguration dcc=dccFactory.createDataConnectionConfiguration();
       
        listenerFactory.setDataConnectionConfiguration(dcc);
       
        server.addListener("default", listenerFactory.createListener());
        return server;
    }
View Full Code Here

        connectClient();
    }

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        Map<String, Ftplet> ftplets = new LinkedHashMap<String, Ftplet>();
        ftplets.put("f1", new MockFtplet());
        server.setFtplets(ftplets);

        return server;
    }
View Full Code Here

        connectClient();
    }

    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        Map<String, Ftplet> ftplets = new LinkedHashMap<String, Ftplet>();
        ftplets.put("f1", new MockFtplet());
        server.setFtplets(ftplets);
       
        return server;
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.FtpServerFactory

Copyright © 2018 www.massapicom. 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.