void Config1() { // Now, let's configure the port on which the default listener waits for connections. FtpServerFactory serverFactory = new FtpServerFactory(); ListenerFactory factory = new ListenerFactory(); PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory(); String[] str = {"mkdir", ftpConfigDir}; try { Process ps = Runtime.getRuntime().exec(str); try { ps.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } String filename = ftpConfigDir + "users.properties"; // "/sdcard/users.properties"; File files = new File(filename); userManagerFactory.setFile(files); serverFactory.setUserManager(userManagerFactory.createUserManager()); // set the port of the listener factory.setPort(2221); // replace the default listener serverFactory.addListener("default", factory.createListener()); // start the server FtpServer server = serverFactory.createServer(); this.mFtpServer = server; try { server.start(); } catch (FtpException e) { e.printStackTrace(); } }
void Config2() { // Now, let's make it possible for a client to use FTPS (FTP over SSL) for the default // listener. 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(ftpConfigDir + "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(ftpConfigDir + "users.properties")); serverFactory.setUserManager(userManagerFactory.createUserManager()); // start the server FtpServer server = serverFactory.createServer(); this.mFtpServer = server; try { server.start(); } catch (FtpException e) { e.printStackTrace(); } }