Package org.apache.ftpserver.listener

Examples of org.apache.ftpserver.listener.ListenerFactory


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());
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

    @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 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);
       
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());

        return server;
    }
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();
       
        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

        FtpServerFactory serverFactory = new FtpServerFactory();

        serverFactory.setConnectionConfig(createConnectionConfigFactory()
                .createConnectionConfig());

        ListenerFactory listenerFactory = new ListenerFactory();

        listenerFactory.setPort(0);

        listenerFactory
                .setDataConnectionConfiguration(createDataConnectionConfigurationFactory()
                        .createDataConnectionConfiguration());

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

        PropertiesUserManagerFactory umFactory = new PropertiesUserManagerFactory();
        umFactory.setAdminName("admin");
        umFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
        umFactory.setFile(USERS_FILE);
View Full Code Here

public class InetAddressBlacklistTest extends ClientTestTemplate {
    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        ListenerFactory factory = new ListenerFactory(server.getListener("default"));

        List<InetAddress> blockedAddresses = new ArrayList<InetAddress>();
        blockedAddresses.add(InetAddress.getByName("localhost"));

        factory.setBlockedAddresses(blockedAddresses);

        server.addListener("default", factory.createListener());
       
        return server;
    }
View Full Code Here

public class SubnetBlacklistTest extends ClientTestTemplate {
    @Override
    protected FtpServerFactory createServer() throws Exception {
        FtpServerFactory server = super.createServer();

        ListenerFactory factory = new ListenerFactory(server.getListener("default"));

        List<Subnet> blockedSubnets = new ArrayList<Subnet>();
        blockedSubnets.add(new Subnet(InetAddress.getByName("localhost"), 32));

        factory.setBlockedSubnets(blockedSubnets);

        server.addListener("default", factory.createListener());
       
        return server;
    }
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();

        passivePort = TestUtil.findFreePort(12444);

        dccFactory.setPassivePorts(String.valueOf(passivePort));

        listenerFactory.setDataConnectionConfiguration(dccFactory
                .createDataConnectionConfiguration());

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

        return server;
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.listener.ListenerFactory

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.