Package org.apache.ftpserver

Examples of org.apache.ftpserver.FtpServer


    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
       
        FtpServer server = (FtpServer) getServletContext().getAttribute(FtpServerListener.FTPSERVER_CONTEXT_NAME);
       
        PrintWriter wr = resp.getWriter();
       
        wr.print("<html>");
        wr.print("<head>");
        wr.print("<title>FtpServer status servlet</title>");
        wr.print("</head>");
        wr.print("<body>");
        wr.print("<form method='post'>");


        if(server.isStopped()) {
            wr.print("<p>FtpServer is stopped.</p>");
        } else {
            if(server.isSuspended()) {
                wr.print("<p>FtpServer is suspended.</p>");
                wr.print("<p><input type='submit' name='resume' value='Resume'></p>");
                wr.print("<p><input type='submit' name='stop' value='Stop'></p>");
            } else {
                wr.print("<p>FtpServer is running.</p>");
View Full Code Here


    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
       
        FtpServer server = (FtpServer) getServletContext().getAttribute(FtpServerListener.FTPSERVER_CONTEXT_NAME);
       
        if(req.getParameter("stop") != null) {
            server.stop();
        } else if(req.getParameter("resume") != null) {
            server.resume();
        } else if(req.getParameter("suspend") != null) {
            server.suspend();
        }
       
        resp.sendRedirect("/");
    }
View Full Code Here

    public static final String FTPSERVER_CONTEXT_NAME = "org.apache.ftpserver";
   
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("Stopping FtpServer");
       
        FtpServer server = (FtpServer) sce.getServletContext().getAttribute(FTPSERVER_CONTEXT_NAME);
       
        if(server != null) {
            server.stop();
           
            sce.getServletContext().removeAttribute(FTPSERVER_CONTEXT_NAME);
           
            System.out.println("FtpServer stopped");
        } else {
View Full Code Here

    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("Starting FtpServer");  

        WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
       
        FtpServer server = (FtpServer) ctx.getBean("myServer");
       
        sce.getServletContext().setAttribute(FTPSERVER_CONTEXT_NAME, server);
       
        try {
            server.start();
            System.out.println("FtpServer started");
        } catch (Exception e) {
            throw new RuntimeException("Failed to start FtpServer", e);
        }
    }
View Full Code Here

        userManagerFactory.setFile(new File("myusers.properties"));
       
        serverFactory.setUserManager(userManagerFactory.createUserManager());
       
        // start the server
        FtpServer server = serverFactory.createServer();
       
        server.start();
    }
View Full Code Here

        AddUser addUser = new AddUser();
       
        try {

            // get configuration
            FtpServer server = addUser.getConfiguration(args);
            if (server == null) {
                return;
            }
           
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
View Full Code Here

       
       
        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...
            //fail("Must throw FtpServerConfigurationException");
        } catch(FtpServerConfigurationException e) {
            if(e.getCause() instanceof BindException) {
                // OK!
               
                // we failed to start, make sure things are shut down correctly
                assertTrue(defaultListener.isStopped());
                assertTrue(secondListener.isStopped());
                assertTrue(server.isStopped());
            } else {
                throw e;
            }
        }
    }
View Full Code Here

                put("sling", wcPlugin);
            }
        });

        try {
            final FtpServer ftpServer = factory.createServer();
            ftpServer.start();
            this.ftpServer = ftpServer;
        } catch (FtpException e) {
            log.error("Cannot start FTP Server", e);
        }
View Full Code Here

        // create servce context
        FtpServerContext ftpConfig = new ConfigurableFtpServerContext(config);

        // create the server object and start it
        return new FtpServer(ftpConfig);
    }
View Full Code Here

            ftpServer.stop();
        }
    }

    protected void initFtpServer() throws Exception {
        ftpServer = new FtpServer();

        // setup user management to read our users.properties and use clear text passwords
        PropertiesUserManager uman = new PropertiesUserManager();
        uman.setFile(new File("./src/test/resources/users.properties").getAbsoluteFile());
        uman.setPasswordEncryptor(new ClearTextPasswordEncryptor());
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.FtpServer

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.