本文整理汇总了Java中org.apache.ftpserver.FtpServer类的典型用法代码示例。如果您正苦于以下问题:Java FtpServer类的具体用法?Java FtpServer怎么用?Java FtpServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FtpServer类属于org.apache.ftpserver包,在下文中一共展示了FtpServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createServer
import org.apache.ftpserver.FtpServer; //导入依赖的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();
}
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:22,代码来源:FTPHelper.java
示例2: setUp
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* @throws Exception
*
* @see junit.framework.TestCase#setUp()
*/
public void setUp() throws Exception {
System.out.println("------------------------- " + getName() + " -------------------------\n");
// clear old home directory
if (new File(FTP_HOME).exists()) {
assertTrue("failed to clear FTP directory", delete(new File(FTP_HOME)));
}
ApplicationContext context = new ClassPathXmlApplicationContext("xml/spring/datup/local/test/InterfaceContext.xml");
this.ftp = (FtpFactory) context.getBean("ftpFactory");
this.config = (Configuration) context.getBean("datupConfiguration");
this.server = (FtpServer) context.getBean("testFtpServer");
server.start();
config.load().setProperty(Configuration.FTP_USERNAME, USER);
config.load().setProperty(Configuration.FTP_PASSWORD, PASS);
config.load().setProperty(Configuration.FTP_HOSTNAME, HOST);
config.load().setProperty(Configuration.FTP_PORT, PORT);
config.load().setProperty(Configuration.FTP_WORKING_DIRECTORY, "pharmacy");
config.load().setProperty(Configuration.FTP_PENDING_DIRECTORY, "pending");
}
开发者ID:OSEHRA-Sandbox,项目名称:MOCHA,代码行数:28,代码来源:FtpTest.java
示例3: createServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
private FtpServer createServer() {
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(FTP_PORT);
serverFactory.addListener("default", listenerFactory.createListener());
PropertiesUserManagerFactory managerFactory = new PropertiesUserManagerFactory();
managerFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
managerFactory.setFile(new File("src/test/resources/users.properties"));
UserManager createUserManager = managerFactory.createUserManager();
serverFactory.setUserManager(createUserManager);
NativeFileSystemFactory fileSystemFactory = new NativeFileSystemFactory();
fileSystemFactory.setCreateHome(true);
serverFactory.setFileSystem(fileSystemFactory);
return serverFactory.createServer();
}
开发者ID:tadayosi,项目名称:samples-switchyard,代码行数:18,代码来源:FTPServer.java
示例4: startFtpServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
public static FtpServer startFtpServer(String homePath, int port, String user, String pass) {
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(port);
serverFactory.addListener("default", listenerFactory.createListener());
serverFactory.setUserManager(new FtpUserManager(homePath, user, pass));
FtpServer ftpServer = serverFactory.createServer();
try {
ftpServer.start();
return ftpServer;
} catch (FtpException e) {
throw new RuntimeException(e);
}
}
开发者ID:bingoohuang,项目名称:aoc,代码行数:17,代码来源:TestUtils.java
示例5: doPost
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
@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("/");
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:17,代码来源:FtpServerServlet.java
示例6: contextInitialized
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
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);
}
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:17,代码来源:FtpServerListener.java
示例7: main
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* This method is the FtpServer starting point when running by using the
* command line mode.
*
* @param args
* The first element of this array must specify the kind of
* configuration to be used to start the server.
*/
public static void main(String args[]) {
CommandLine cli = new CommandLine();
try {
// get configuration
FtpServer server = cli.getConfiguration(args);
if (server == null) {
return;
}
// start the server
server.start();
System.out.println("FtpServer started");
// add shutdown hook if possible
cli.addShutdownHook(server);
} catch (Exception ex) {
ex.printStackTrace();
}
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:30,代码来源:CommandLine.java
示例8: createServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
protected FtpServer createServer(String config) {
String completeConfig = "<server id=\"server\" xmlns=\"http://mina.apache.org/ftpserver/spring/v1\" "
+ "xmlns:beans=\"http://www.springframework.org/schema/beans\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\" "
+ "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd "
+ "http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd "
+ "\">"
+ config
+ "</server>";
XmlBeanFactory factory = new XmlBeanFactory(
new ByteArrayResource(completeConfig.getBytes()));
return (FtpServer) factory.getBean("server");
}
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:18,代码来源:SpringConfigTestTemplate.java
示例9: startServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* Start the FTP server.
*/
public void startServer() {
//Set the user factory
PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
String filename = mContext.getExternalCacheDir().getAbsolutePath() + "/users.properties";
File files = new File(filename);
userManagerFactory.setFile(files);
//Set the server factory
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userManagerFactory.createUserManager());
//Set the port number
ListenerFactory factory = new ListenerFactory();
factory.setPort(PORT_NUMBER);
try {
serverFactory.addListener("default", factory.createListener());
FtpServer server = serverFactory.createServer();
mFtpServer = server;
//Start the server
server.start();
} catch (FtpException e) {
e.printStackTrace();
}
Log.d(TAG, "onCreate: FTP server started. IP address: " + getLocalIpAddress() + " and Port:" + PORT_NUMBER);
}
开发者ID:kevalpatel2106,项目名称:remote-storage-android-things,代码行数:31,代码来源:FTPManager.java
示例10: Config2
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
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();
}
}
开发者ID:lucky-code,项目名称:Practice,代码行数:38,代码来源:FtpActivity.java
示例11: startServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
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);
}
}
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:30,代码来源:TestFTPFileSystem.java
示例12: ftpServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
@Bean
FtpServer ftpServer(UserManager userManager, Listener nioListener, FileSystemFactory fileSystemFactory) throws FtpException {
FtpServerFactory ftpServerFactory = new FtpServerFactory();
ftpServerFactory.setListeners(Collections.singletonMap("default", nioListener));
ftpServerFactory.setFileSystem(fileSystemFactory);
ftpServerFactory.setUserManager(userManager);
return ftpServerFactory.createServer();
}
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:9,代码来源:FtpServerConfiguration.java
示例13: testInitBySpring
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* Test method for {@link ch.sdi.core.impl.ftp.FtpExecutor#executeUpload(java.io.InputStream, java.lang.String)}.
*/
@Test
public void testInitBySpring() throws Throwable
{
myLog.debug( "Testing self-initialize by Spring context" );
String targetDir = myTargetDirLocal;
cleanTargetDir( targetDir );
Map<String, InputStream> filesToUpload = createFileUploadMap( targetDir );
TestUtils.addToEnvironment( myEnv, SdiMainProperties.KEY_FTP_CMD_LINE,
"-A localhost" );
registerFtpUser( "anonymous",
System.getProperty( "user.name" ) + "@" + InetAddress.getLocalHost().getHostName() );
FtpServer server = startFtpServer();
try
{
// omit call to init in order to auto initialize by spring context
myClassUnderTest.connectAndLogin();
myClassUnderTest.uploadFiles( filesToUpload );
myClassUnderTest.logoutAndDisconnect();
assertFilesUploaded( createFileUploadMap( targetDir ) );
}
finally
{
if ( server != null )
{
myLog.debug( "stopping the embedded FTP server" );
server.stop();
} // if myServer != null
}
}
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:37,代码来源:FtpExecutorTest.java
示例14: testUploadAnonymous
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* Test method for {@link ch.sdi.core.impl.ftp.FtpExecutor#executeUpload(java.io.InputStream, java.lang.String)}.
*/
@Test
public void testUploadAnonymous() throws Throwable
{
myLog.debug( "Testing Anonymous login" );
String targetDir = myTargetDirLocal;
cleanTargetDir( targetDir );
Map<String, InputStream> filesToUpload = createFileUploadMap( targetDir );
List<String> args = new ArrayList<String>();
args.add( "-bla" ); // invalid option should be ignored
args.add( "-A" ); // anonymous
args.add( "localhost" );
registerFtpUser( "anonymous",
System.getProperty( "user.name" ) + "@" + InetAddress.getLocalHost().getHostName() );
FtpServer server = startFtpServer();
try
{
myClassUnderTest.init( args.toArray( new String[args.size()] ) );
myClassUnderTest.connectAndLogin();
myClassUnderTest.uploadFiles( filesToUpload );
myClassUnderTest.logoutAndDisconnect();
assertFilesUploaded( createFileUploadMap( targetDir ) );
}
finally
{
if ( server != null )
{
myLog.debug( "stopping the embedded FTP server" );
server.stop();
} // if myServer != null
}
}
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:39,代码来源:FtpExecutorTest.java
示例15: testUploadLogin
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* Test method for {@link ch.sdi.core.impl.ftp.FtpExecutor#executeUpload(java.io.InputStream, java.lang.String)}.
*/
@Test
public void testUploadLogin() throws Throwable
{
myLog.debug( "Testing normal login" );
String targetDir = myTargetDirLocal;
cleanTargetDir( targetDir );
Map<String, InputStream> filesToUpload = createFileUploadMap( targetDir );
List<String> args = new ArrayList<String>();
args.add( "localhost" );
args.add( "heri" ); // user
args.add( "heri" ); // pw
registerFtpUser( "heri", "heri" );
FtpServer server = startFtpServer();
try
{
myClassUnderTest.init( args.toArray( new String[args.size()] ) );
myClassUnderTest.connectAndLogin();
myClassUnderTest.uploadFiles( filesToUpload );
myClassUnderTest.logoutAndDisconnect();
assertFilesUploaded( createFileUploadMap( targetDir ) );
}
finally
{
if ( server != null )
{
myLog.debug( "stopping the embedded FTP server" );
server.stop();
} // if myServer != null
}
}
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:38,代码来源:FtpExecutorTest.java
示例16: startFtpServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
/**
* @return
* @throws FtpException
*/
private FtpServer startFtpServer() throws FtpException
{
FtpServer result;
result = myServerFactory.createServer();
myLog.debug( "starting an embedded FTP server" );
result.start();
return result;
}
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:14,代码来源:FtpExecutorTest.java
示例17: configureFtpServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
@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();
}
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:9,代码来源:CamelFtpTest.java
示例18: ServiceNG
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
public ServiceNG(boolean enable_play, boolean enable_ftpserver, boolean enable_background_services) throws Exception {
EmbDDB embddb = MyDMAM.getEmbDDB();
if (embddb != null) {
embddb.startServers();
}
CassandraDb.autotest();
this.enable_play = enable_play;
this.enable_ftpserver = enable_ftpserver;
this.enable_background_services = enable_background_services;
shutdown_hook = new ShutdownHook();
Runtime.getRuntime().addShutdownHook(shutdown_hook);
StringJoiner names = new StringJoiner(", ");
if (enable_play) {
names.add("Play server");
}
if (enable_ftpserver) {
names.add("FTP Server");
}
if (enable_background_services && enable_play == false && enable_ftpserver == false) {
names.add("Background services");
}
manager = new AppManager(names.toString());
WatchdogLogConf watch_log_conf = new WatchdogLogConf();
watch_log_conf.start();
if (enable_ftpserver) {
ftp_servers = new ArrayList<FtpServer>();
FTPGroup.registerAppManager(this.manager);
}
}
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:37,代码来源:ServiceNG.java
示例19: createServer
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
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();
}
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:35,代码来源:FtpsServer.java
示例20: ftpInDirectOutput
import org.apache.ftpserver.FtpServer; //导入依赖的package包/类
@Test
public void ftpInDirectOutput() throws IOException {
int ftpPort = TestUtils.choosePort();
File remoteFile = new File("./20131217.remote.txt");
remoteFile.deleteOnExit();
new File("./20131217.local.txt").deleteOnExit();
FileUtils.writeStringToFile(remoteFile, "a,b,c,d\na1,b1,c1", Charsets.UTF_8);
FtpServer ftpServer = TestUtils.startFtpServer(".", ftpPort, "user", "pass");
Properties config = new Properties();
config.put("alias." + FtpInput.class.getSimpleName(), FtpInput.class.getName());
config.put("input", "@" + FtpInput.class.getSimpleName() + "(ftp)");
config.put("ftp.host", "127.0.0.1");
config.put("ftp.port", "" + ftpPort);
config.put("ftp.user", "user");
config.put("ftp.password", "pass");
config.put("ftp.remote", "${checkDay}.remote.txt");
config.put("ftp.local", "${checkDay}.local.txt");
config.put("filter", "@" + TextFileFilter.class.getName() + "(text)");
config.put("text.data.fields.split", ",");
config.put("text.data.fields.from", "A,B,C");
config.put("text.data.fields.to", "A,C");
config.put("output", "@" + DirectOutput.class.getName());
AocContext aocContext = new AocContext();
aocContext.setCheckDay("20131217");
Processor processor = Processor.fromProperties(config).aocContext(aocContext);
processor.process();
DirectOutput output = (DirectOutput) processor.output();
assertThat(output.getContent(), is("A,C\na,c\na1,c1\n"));
ftpServer.stop();
}
开发者ID:bingoohuang,项目名称:aoc,代码行数:40,代码来源:SimpleTest.java
注:本文中的org.apache.ftpserver.FtpServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论