org.apache.ftpserver.FtpServer Java Examples
The following examples show how to use
org.apache.ftpserver.FtpServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelFtpTest.java From jbpm-work-items with Apache License 2.0 | 5 votes |
@Override protected FtpServer configureFtpServer(CamelFtpBaseTest.FtpServerBuilder builder) throws FtpException { ListenerFactory listenerFactory = new ListenerFactory(); listenerFactory.setServerAddress(HOST); listenerFactory.setPort(PORT); return builder.addUser(USER, PASSWD, ftpRoot, true).registerDefaultListener(listenerFactory.createListener()).build(); }
Example #2
Source File: CamelFtpsTest.java From jbpm-work-items with Apache License 2.0 | 5 votes |
@Override protected FtpServer configureFtpServer(CamelFtpBaseTest.FtpServerBuilder builder) throws FtpException { ListenerFactory listenerFactory = configureSSL(); return builder.addUser(USER, PASSWD, ftpRoot, true).registerDefaultListener(listenerFactory.createListener()).build(); }
Example #3
Source File: TestFTPFileSystem.java From RDFS with Apache License 2.0 | 5 votes |
private void startServer() { try { DefaultFtpServerContext context = new DefaultFtpServerContext(false); MinaListener listener = new MinaListener(); // Set port to 0 for OS to give a free port listener.setPort(0); context.setListener("default", listener); // Create a test user. UserManager userManager = context.getUserManager(); BaseUser adminUser = new BaseUser(); adminUser.setName("admin"); adminUser.setPassword("admin"); adminUser.setEnabled(true); adminUser.setAuthorities(new Authority[] { new WritePermission() }); Path adminUserHome = new Path(ftpServerRoot, "user/admin"); adminUser.setHomeDirectory(adminUserHome.toUri().getPath()); adminUser.setMaxIdleTime(0); userManager.save(adminUser); // Initialize the server and start. server = new FtpServer(context); server.start(); } catch (Exception e) { throw new RuntimeException("FTP server start-up failed", e); } }
Example #4
Source File: FtpsServer.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private FtpServer createServer( int port, String username, String password, boolean implicitSsl ) throws Exception { ListenerFactory factory = new ListenerFactory(); factory.setPort( port ); if ( implicitSsl ) { SslConfigurationFactory ssl = new SslConfigurationFactory(); ssl.setKeystoreFile( new File( SERVER_KEYSTORE ) ); ssl.setKeystorePassword( PASSWORD ); // set the SSL configuration for the listener factory.setSslConfiguration( ssl.createSslConfiguration() ); factory.setImplicitSsl( true ); } FtpServerFactory serverFactory = new FtpServerFactory(); // replace the default listener serverFactory.addListener( "default", factory.createListener() ); PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory(); userManagerFactory.setFile( new File( SERVER_USERS ) ); UserManager userManager = userManagerFactory.createUserManager(); if ( !userManager.doesExist( username ) ) { BaseUser user = new BaseUser(); user.setName( username ); user.setPassword( password ); user.setEnabled( true ); user.setHomeDirectory( USER_HOME_DIR ); user.setAuthorities( Collections.<Authority>singletonList( new WritePermission() ) ); userManager.save( user ); } serverFactory.setUserManager( userManager ); return serverFactory.createServer(); }
Example #5
Source File: TestFTPFileSystem.java From hadoop-gpu with Apache License 2.0 | 5 votes |
private void startServer() { try { DefaultFtpServerContext context = new DefaultFtpServerContext(false); MinaListener listener = new MinaListener(); // Set port to 0 for OS to give a free port listener.setPort(0); context.setListener("default", listener); // Create a test user. UserManager userManager = context.getUserManager(); BaseUser adminUser = new BaseUser(); adminUser.setName("admin"); adminUser.setPassword("admin"); adminUser.setEnabled(true); adminUser.setAuthorities(new Authority[] { new WritePermission() }); Path adminUserHome = new Path(ftpServerRoot, "user/admin"); adminUser.setHomeDirectory(adminUserHome.toUri().getPath()); adminUser.setMaxIdleTime(0); userManager.save(adminUser); // Initialize the server and start. server = new FtpServer(context); server.start(); } catch (Exception e) { throw new RuntimeException("FTP server start-up failed", e); } }
Example #6
Source File: StorageServerTools.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public static FtpServer start(StorageServer storageServer) throws Exception { /** 服务器工厂 */ FtpServerFactory serverFactory = new FtpServerFactory(); /*** 连接工厂 */ ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory(); connectionConfigFactory.setAnonymousLoginEnabled(false); connectionConfigFactory.setMaxLogins(1000); connectionConfigFactory.setMaxThreads(1000); /** 监听工厂 */ ListenerFactory listenerFactory = new ListenerFactory(); /** 数据传输工厂,在监听工厂使用 */ DataConnectionConfigurationFactory dataConnectionConfigurationFactory = new DataConnectionConfigurationFactory(); /** * 如果不指定端口会WARN:<br/> * <p> * WARN org.apache.ftpserver.impl.PassivePorts - Releasing unreserved passive * port: 41662 * </p> */ dataConnectionConfigurationFactory.setPassivePorts(storageServer.getPassivePorts()); // /**强制不使用ip检查?不知道啥意思*/ dataConnectionConfigurationFactory.setPassiveIpCheck(false); listenerFactory .setDataConnectionConfiguration(dataConnectionConfigurationFactory.createDataConnectionConfiguration()); listenerFactory.setPort(storageServer.getPort()); // if (storageServer.getSslEnable()) { // File keystoreFile = new File(Config.base(), "config/o2.keystore"); // SslConfigurationFactory ssl = new SslConfigurationFactory(); // ssl.setKeystoreFile(keystoreFile); // ssl.setKeystorePassword(Config.token().getSsl()); // listenerFactory.setSslConfiguration(ssl.createSslConfiguration()); // listenerFactory.setImplicitSsl(true); // } Listener listener = listenerFactory.createListener(); serverFactory.addListener("default", listener); serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig()); serverFactory.setUserManager(calculateUserManager(storageServer.getCalculatedAccounts())); FtpServer server = serverFactory.createServer(); server.start(); System.out.println("****************************************"); System.out.println("* storage server start completed."); System.out.println("* port: " + storageServer.getPort() + "."); System.out.println("****************************************"); return server; }
Example #7
Source File: StorageServerTools.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public static void stop(FtpServer server) throws Exception { if ((server != null) && (!server.isStopped())) { server.stop(); } }
Example #8
Source File: CamelFtpBaseTest.java From jbpm-work-items with Apache License 2.0 | 4 votes |
public FtpServer build() { return ftpServerFactory.createServer(); }
Example #9
Source File: SftpServerRule.java From nomulus with Apache License 2.0 | 4 votes |
private static FtpServer createSftpServer(String user, String pass, File home, int port) throws FtpException { FtpServer server = TestSftpServer.createSftpServer(user, pass, null, port, home); server.start(); return server; }
Example #10
Source File: CommandLineExt.java From JPPF with Apache License 2.0 | 2 votes |
/** * Create and start the ftpd server * @return an <code>FtpServer</code> instance. * @throws Exception if any error occurs. */ public FtpServer createServer() throws Exception { return super.getConfiguration(new String[] { configFile }); }
Example #11
Source File: FTPServerStartup.java From JPPF with Apache License 2.0 | 1 votes |
/** * Get the underlying embedded FTP server. * @return an <code>FtpServer</code> instance. */ public FtpServer getServer() { return server; }
Example #12
Source File: CamelFtpBaseTest.java From jbpm-work-items with Apache License 2.0 | votes |
protected abstract FtpServer configureFtpServer(FtpServerBuilder builder) throws FtpException;