use of org.apache.ftpserver.ssl.SslConfigurationFactory 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();
}
use of org.apache.ftpserver.ssl.SslConfigurationFactory in project camel by apache.
the class FtpsServerTestSupport method createSslConfiguration.
protected SslConfigurationFactory createSslConfiguration() {
// comment in, if you have trouble with SSL
// System.setProperty("javax.net.debug", "all");
SslConfigurationFactory sslConfigFactory = new SslConfigurationFactory();
sslConfigFactory.setSslProtocol(getAuthValue());
sslConfigFactory.setKeystoreFile(FTPSERVER_KEYSTORE);
sslConfigFactory.setKeystoreType("JKS");
sslConfigFactory.setKeystoreAlgorithm("SunX509");
sslConfigFactory.setKeystorePassword(FTPSERVER_KEYSTORE_PASSWORD);
sslConfigFactory.setKeyPassword(FTPSERVER_KEYSTORE_PASSWORD);
sslConfigFactory.setClientAuthentication(getClientAuth());
if (Boolean.valueOf(getClientAuth())) {
sslConfigFactory.setTruststoreFile(FTPSERVER_KEYSTORE);
sslConfigFactory.setTruststoreType("JKS");
sslConfigFactory.setTruststoreAlgorithm("SunX509");
sslConfigFactory.setTruststorePassword(FTPSERVER_KEYSTORE_PASSWORD);
}
return sslConfigFactory;
}
use of org.apache.ftpserver.ssl.SslConfigurationFactory in project ddf by codice.
the class FtpServerStarterTest method setup.
@Before
public void setup() {
Ftplet ftplet = mock(FtpRequestHandler.class);
ftpServerFactory = mock(FtpServerFactory.class);
listenerFactory = mock(ListenerFactory.class);
UserManager userManager = mock(UserManagerImpl.class);
sslConfigurationFactory = mock(SslConfigurationFactory.class);
defaultListener = mock(Listener.class);
server = mock(DefaultFtpServer.class, RETURNS_DEEP_STUBS);
sessions = new HashSet<>();
ftpServerStarter = new FtpServerStarter(ftplet, ftpServerFactory, listenerFactory, userManager, sslConfigurationFactory);
}
Aggregations