Hello.

I am using Windows XP and ftp server version 1.0.2.

Test case.  I have written a very simple one class FTP server (how easy) to
demo the problem that I am having.  The code below creates and FTP server
with one listener on port 21.

It then suspends that listener, but an FTP connection from the command line
can still be made. If I *stop() *the listener instead, I get the original
exception.

I can post the process for my application code if required.

Cheers


*package ftp;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.ftpserver.ConnectionConfigFactory;
import org.apache.ftpserver.DataConnectionConfigurationFactory;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.Authority;
import org.apache.ftpserver.ftplet.Ftplet;
import org.apache.ftpserver.ftplet.UserManager;
import org.apache.ftpserver.impl.DefaultFtpServer;
import org.apache.ftpserver.listener.Listener;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
import org.apache.ftpserver.usermanager.impl.BaseUser;
import org.apache.ftpserver.usermanager.impl.WritePermission;
import siemens.mobility.vacs.ocf.jca.inbound.ServerFTPLet;


public class MainFTPServerTest
{

    private static DefaultFtpServer server = null;

    public static void main(String[] args) throws Exception
    {
        FtpServerFactory serverFactory = new
FtpServerFactory();

        ConnectionConfigFactory connConfigFactory = new
ConnectionConfigFactory();

        connConfigFactory.setMaxLogins(1000);
        connConfigFactory.setAnonymousLoginEnabled(false);

serverFactory.setConnectionConfig(connConfigFactory.createConnectionConfig());

        Map<String, Ftplet> fptLets =
serverFactory.getFtplets();
        fptLets.put("FTPLet", new ServerFTPLet());

        PropertiesUserManagerFactory userManagerFactory = new
PropertiesUserManagerFactory();
        userManagerFactory.setPasswordEncryptor(new
ClearTextPasswordEncryptor());
        UserManager userManager = userManagerFactory.createUserManager();

        BaseUser user = new BaseUser();
        user.setName("user");
        user.setPassword("password");

        List<Authority> auths = new ArrayList<Authority>();
        auths.add(new WritePermission());

        user.setAuthorities(auths);
        userManager.save(user);

        serverFactory.setUserManager(userManager);


        // start the server
        server = (DefaultFtpServer)serverFactory.createServer();
        server.getListeners().clear();

        server.getListeners().put("127.0.0.1",
createListener());

        for (Listener listener : server.getListeners().values())
        {
            listener.start(server.getServerContext());
        }

        server.start();

        for (Listener listener : server.getListeners().values())
        {
            listener.suspend();
        }
    }

    public static DefaultFtpServer getServer()
    {
        return server;
    }

    private static Listener createListener()
    {
        ListenerFactory listenFactory = new ListenerFactory();
        listenFactory.setPort(21);
        listenFactory.setServerAddress("127.0.0.1");

        DataConnectionConfigurationFactory dataConnFactory = new
DataConnectionConfigurationFactory();
        dataConnFactory.setIdleTime(0);


listenFactory.setDataConnectionConfiguration(dataConnFactory.createDataConnectionConfiguration());
        Listener result = listenFactory.createListener();
        return result;
    }

}*


On Tue, Sep 14, 2010 at 12:57 PM, Niklas Gustavsson <[email protected]>wrote:

> On Tue, Sep 14, 2010 at 1:40 PM, Aidan Diffey <[email protected]>
> wrote:
> > I tried the suspend() command on the listener, but I could still make an
> FTP
> > connection to the IP address and port. A netstat -an also shows me the
> > ip-address and port are LISTENING.
>
> Just tested and this is not the behavior I'm seeing. What OS and
> FtpServer version is this on? Also, could you provide some test case
> for how your code works?
>
> /niklas
>

Reply via email to