Search in sources :

Example 1 with NativeFileSystemFactory

use of org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory in project quickstarts by jboss-switchyard.

the class CamelFtpBindingTest method startUp.

@BeforeClass
public static void startUp() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    ListenerFactory listenerFactory = new ListenerFactory();
    listenerFactory.setPort(2222);
    serverFactory.addListener("default", listenerFactory.createListener());
    ListenerFactory sslListenerFactory = new ListenerFactory();
    sslListenerFactory.setPort(2221);
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile(new File("src/test/resources/ftpserver.jks"));
    ssl.setKeystorePassword("password");
    sslListenerFactory.setSslConfiguration(ssl.createSslConfiguration());
    // Setting it to true will not read the file
    sslListenerFactory.setImplicitSsl(false);
    serverFactory.addListener("ftps", sslListenerFactory.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);
    File file = new File("target/ftp/ftps");
    file.mkdirs();
    file = new File("target/ftp/sftp");
    file.mkdirs();
    ftpServer = serverFactory.createServer();
    ftpServer.start();
    SshServer sshd = SshServer.setUpDefaultServer();
    sshd.setPort(2220);
    sshd.setKeyPairProvider(createTestKeyPairProvider("src/test/resources/hostkey.pem"));
    sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
    sshd.setCommandFactory(new ScpCommandFactory());
    sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
    sshd.start();
    JSch sch = new JSch();
    Session session = sch.getSession("camel", "localhost", 2220);
    session.setUserInfo(new SimpleUserInfo("isMyFriend"));
    session.connect();
    ChannelSftp c = (ChannelSftp) session.openChannel("sftp");
    c.connect();
    System.out.println("Home: " + c.getHome());
    c.chmod(777, ".");
    c.chmod(777, "target");
    c.chmod(777, "target/ftp");
    c.chmod(777, "target/ftp/sftp");
    c.disconnect();
    session.disconnect();
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) ScpCommandFactory(org.apache.sshd.server.command.ScpCommandFactory) PropertiesUserManagerFactory(org.apache.ftpserver.usermanager.PropertiesUserManagerFactory) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory) SslConfigurationFactory(org.apache.ftpserver.ssl.SslConfigurationFactory) FtpServerFactory(org.apache.ftpserver.FtpServerFactory) NamedFactory(org.apache.sshd.common.NamedFactory) JSch(com.jcraft.jsch.JSch) ClearTextPasswordEncryptor(org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor) SshServer(org.apache.sshd.SshServer) ScpCommandFactory(org.apache.sshd.server.command.ScpCommandFactory) ChannelSftp(com.jcraft.jsch.ChannelSftp) Command(org.apache.sshd.server.Command) UserManager(org.apache.ftpserver.ftplet.UserManager) PropertiesUserManagerFactory(org.apache.ftpserver.usermanager.PropertiesUserManagerFactory) SslConfigurationFactory(org.apache.ftpserver.ssl.SslConfigurationFactory) File(java.io.File) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory) ServerSession(org.apache.sshd.server.session.ServerSession) Session(com.jcraft.jsch.Session) BeforeClass(org.junit.BeforeClass)

Example 2 with NativeFileSystemFactory

use of org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory in project camel by apache.

the class FtpAndHttpRecipientListInterceptSendToEndpointIssueTest method initFtpServer.

protected void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    // setup user management to read our users.properties and use clear text passwords
    File file = new File("src/test/resources/users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), file, "admin");
    serverFactory.setUserManager(uman);
    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);
    ListenerFactory factory = new ListenerFactory();
    factory.setPort(ftpPort);
    serverFactory.addListener("default", factory.createListener());
    ftpServer = serverFactory.createServer();
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) UserManager(org.apache.ftpserver.ftplet.UserManager) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) File(java.io.File) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) ClearTextPasswordEncryptor(org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory)

Example 3 with NativeFileSystemFactory

use of org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory in project camel by apache.

the class FtpXQueryTest method initFtpServer.

protected void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    // setup user management to read our users.properties and use clear text passwords
    File file = new File("src/test/resources/users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), file, "admin");
    serverFactory.setUserManager(uman);
    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);
    ListenerFactory factory = new ListenerFactory();
    factory.setPort(ftpPort);
    serverFactory.addListener("default", factory.createListener());
    ftpServer = serverFactory.createServer();
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) UserManager(org.apache.ftpserver.ftplet.UserManager) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) File(java.io.File) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) ClearTextPasswordEncryptor(org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory)

Example 4 with NativeFileSystemFactory

use of org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory in project camel by apache.

the class SpringFileAntPathMatcherRemoteFileFilterTest method initFtpServer.

protected void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    // setup user management to read our users.properties and use clear text passwords
    File file = new File("src/test/resources/users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), file, "admin");
    serverFactory.setUserManager(uman);
    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);
    ListenerFactory factory = new ListenerFactory();
    factory.setPort(ftpPort);
    serverFactory.addListener("default", factory.createListener());
    ftpServer = serverFactory.createServer();
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) UserManager(org.apache.ftpserver.ftplet.UserManager) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) File(java.io.File) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) ClearTextPasswordEncryptor(org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory)

Example 5 with NativeFileSystemFactory

use of org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory in project camel by apache.

the class FtpCronScheduledRoutePolicyTest method initFtpServer.

protected void initFtpServer() throws Exception {
    FtpServerFactory serverFactory = new FtpServerFactory();
    // setup user management to read our users.properties and use clear text passwords
    File file = new File("src/test/resources/users.properties");
    UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), file, "admin");
    serverFactory.setUserManager(uman);
    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);
    serverFactory.setFileSystem(fsf);
    ListenerFactory factory = new ListenerFactory();
    factory.setPort(20128);
    serverFactory.addListener("default", factory.createListener());
    ftpServer = serverFactory.createServer();
}
Also used : FtpServerFactory(org.apache.ftpserver.FtpServerFactory) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) UserManager(org.apache.ftpserver.ftplet.UserManager) NativeFileSystemFactory(org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory) File(java.io.File) PropertiesUserManager(org.apache.ftpserver.usermanager.impl.PropertiesUserManager) ClearTextPasswordEncryptor(org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory)

Aggregations

FtpServerFactory (org.apache.ftpserver.FtpServerFactory)7 NativeFileSystemFactory (org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory)7 UserManager (org.apache.ftpserver.ftplet.UserManager)7 ListenerFactory (org.apache.ftpserver.listener.ListenerFactory)7 ClearTextPasswordEncryptor (org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor)7 File (java.io.File)6 PropertiesUserManager (org.apache.ftpserver.usermanager.impl.PropertiesUserManager)5 PropertiesUserManagerFactory (org.apache.ftpserver.usermanager.PropertiesUserManagerFactory)2 ChannelSftp (com.jcraft.jsch.ChannelSftp)1 JSch (com.jcraft.jsch.JSch)1 Session (com.jcraft.jsch.Session)1 ConnectionConfigFactory (org.apache.ftpserver.ConnectionConfigFactory)1 SslConfigurationFactory (org.apache.ftpserver.ssl.SslConfigurationFactory)1 SshServer (org.apache.sshd.SshServer)1 NamedFactory (org.apache.sshd.common.NamedFactory)1 Command (org.apache.sshd.server.Command)1 ScpCommandFactory (org.apache.sshd.server.command.ScpCommandFactory)1 ServerSession (org.apache.sshd.server.session.ServerSession)1 BeforeClass (org.junit.BeforeClass)1