本文整理汇总了Java中org.apache.ftpserver.ConnectionConfigFactory类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionConfigFactory类的具体用法?Java ConnectionConfigFactory怎么用?Java ConnectionConfigFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionConfigFactory类属于org.apache.ftpserver包,在下文中一共展示了ConnectionConfigFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFtpServerFactory
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
protected FtpServerFactory createFtpServerFactory() throws Exception {
assertTrue(USERS_FILE.exists());
assertTrue("Port number is not initialized in an expected range: " + BaseServerTestSupport.port, BaseServerTestSupport.port >= 21000);
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
pumf.setAdminName("admin");
pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
pumf.setFile(USERS_FILE);
UserManager userMgr = pumf.createUserManager();
ListenerFactory factory = new ListenerFactory();
factory.setPort(BaseServerTestSupport.port);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userMgr);
serverFactory.setFileSystem(fsf);
serverFactory.setConnectionConfig(new ConnectionConfigFactory().createConnectionConfig());
serverFactory.addListener(DEFAULT_LISTENER, factory.createListener());
return serverFactory;
}
示例2: createServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
public static FtpServer createServer(int port, int maxLoginFailures, int loginFailureDelay,
boolean anonymousEnable, String anonymousHomeDirectory,
FTPUser... users) {
final ListenerFactory listener = new ListenerFactory();
listener.setPort(port);
listener.setDataConnectionConfiguration(
new DataConnectionConfigurationFactory().createDataConnectionConfiguration());
ConnectionConfigFactory connection = new ConnectionConfigFactory();
connection.setMaxLoginFailures(maxLoginFailures);
connection.setLoginFailureDelay(loginFailureDelay);
connection.setAnonymousLoginEnabled(anonymousEnable);
final FtpServerFactory server = new FtpServerFactory();
server.setUserManager(new FTPUserManager(anonymousEnable, anonymousHomeDirectory, users));
server.setFileSystem(FTPFileSystemFactory.getInstance());
server.addListener("default", listener.createListener());
server.setConnectionConfig(connection.createConnectionConfig());
return server.createServer();
}
示例3: setupFTPServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
@BeforeClass
public static void setupFTPServer() throws Exception
{
FtpServerFactory serverFactory = new FtpServerFactory();
ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
connectionConfigFactory.setAnonymousLoginEnabled(true);
serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
BaseUser user = new BaseUser();
user.setHomeDirectory(Paths.get(FSBuilder.DIR_FOR_TEST_TREE).toAbsolutePath().toString());
user.setName("anonymous");
serverFactory.getUserManager().save(user);
ListenerFactory factory = new ListenerFactory();
factory.setPort(2221);
serverFactory.addListener("default", factory.createListener());
server = serverFactory.createServer();
server.start();
}
示例4: start
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
/**
* Start.
*/
public boolean start(){
stop();
ConnectionConfigFactory configFactory = new ConnectionConfigFactory();
configFactory.setAnonymousLoginEnabled(false);
configFactory.setMaxAnonymousLogins(0);
configFactory.setMaxLoginFailures(5);
configFactory.setLoginFailureDelay(30);
configFactory.setMaxThreads(10);
configFactory.setMaxLogins(10);
ListenerFactory factory = new ListenerFactory();
factory.setPort(port);
factory.setIdleTimeout(60);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.addListener("default", factory.createListener());
serverFactory.setUserManager(userManager);
serverFactory.setConnectionConfig(configFactory.createConnectionConfig());
server = serverFactory.createServer();
try{
server.start();
} catch (FtpException ex){
System.err.println(ex.getMessage());
return false;
}
return true;
}
示例5: init
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
private void init() {
setFileSystem(new FtpFileSystemView());
ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
connectionConfigFactory.setMaxThreads(10);
connectionConfigFactory.setAnonymousLoginEnabled(true);
setConnectionConfig(connectionConfigFactory.createConnectionConfig());
setUserManager(new FtpUserManagerFactory().createUserManager());
// MFMT for directories (default mina command doesn't support it)
CommandFactoryFactory ccf = new CommandFactoryFactory();
ccf.addCommand("MFMT", new FtpCommands.MFMT());
setCommandFactory(ccf.createCommandFactory());
// TODO: set ftplet to control all commands
Map<String,Ftplet> ftplets = new HashMap<String,Ftplet>();
ftplets.put("default", new FtpletController());
setFtplets(ftplets);
// set the port of the listener
int port = Integer.parseInt(configuration.getProperty("port", String.valueOf(1821)));
String serverAddress = configuration.getProperty("server", "");
LOG.info("FTP server configured at '" + serverAddress + ":" + port + "'");
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(port);
if (!serverAddress.isEmpty()){
listenerFactory.setServerAddress(serverAddress);
}
// replace the default listener
addListener("default", listenerFactory.createListener());
}
示例6: createServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
@Override
protected FtpServerFactory createServer() throws Exception {
FtpServerFactory server = super.createServer();
ConnectionConfigFactory ccFactory = new ConnectionConfigFactory();
ccFactory.setMaxLoginFailures(0);
server.setConnectionConfig(ccFactory.createConnectionConfig());
return server;
}
示例7: startFtpServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
@Before
public void startFtpServer() throws Exception {
recursiveDelete(resolvePath(FTP_ROOT_DIR).toFile());
File usersFile = USERS_FILE.toFile();
usersFile.createNewFile();
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
pumf.setAdminName("admin");
pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
pumf.setFile(usersFile);
UserManager userMgr = pumf.createUserManager();
BaseUser user = new BaseUser();
user.setName("admin");
user.setPassword("admin");
user.setHomeDirectory(FTP_ROOT_DIR.toString());
List<Authority> authorities = new ArrayList<>();
WritePermission writePermission = new WritePermission();
writePermission.authorize(new WriteRequest());
authorities.add(writePermission);
user.setAuthorities(authorities);
userMgr.save(user);
ListenerFactory factory1 = new ListenerFactory();
factory1.setPort(PORT);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userMgr);
serverFactory.setFileSystem(fsf);
serverFactory.setConnectionConfig(new ConnectionConfigFactory().createConnectionConfig());
serverFactory.addListener("default", factory1.createListener());
FtpServerFactory factory = serverFactory;
ftpServer = factory.createServer();
ftpServer.start();
}
示例8: createConnectionConfigFactory
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
protected ConnectionConfigFactory createConnectionConfigFactory() {
return new ConnectionConfigFactory();
}
示例9: createServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
@Override
protected FtpServerFactory createServer() throws Exception {
FtpServerFactory server = super.createServer();
ConnectionConfigFactory ccFactory = new ConnectionConfigFactory();
ccFactory.setMaxLoginFailures(2);
server.setConnectionConfig(ccFactory.createConnectionConfig());
return server;
}
示例10: createServer
import org.apache.ftpserver.ConnectionConfigFactory; //导入依赖的package包/类
@Override
protected FtpServerFactory createServer() throws Exception {
FtpServerFactory server = super.createServer();
ConnectionConfigFactory ccFactory = new ConnectionConfigFactory();
ccFactory.setAnonymousLoginEnabled(false);
server.setConnectionConfig(ccFactory.createConnectionConfig());
return server;
}