org.apache.ftpserver.ssl.SslConfigurationFactory Java Examples
The following examples show how to use
org.apache.ftpserver.ssl.SslConfigurationFactory.
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: CamelFtpsTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
private ListenerFactory configureSSL() { ListenerFactory listener = new ListenerFactory(); listener.setServerAddress("127.0.0.1"); listener.setPort(PORT); SslConfigurationFactory ssl = new SslConfigurationFactory(); ssl.setKeystoreFile(SERVER_SSL_KEY_TRUST_STORE); ssl.setKeyPassword(SERVER_SSL_KEY_PASSWD); ssl.setKeystorePassword(SERVER_SSL_STORE_PASSWD); ssl.setTruststoreFile(SERVER_SSL_KEY_TRUST_STORE); ssl.setTruststorePassword(SERVER_SSL_STORE_PASSWD); ssl.setClientAuthentication("NEED"); SslConfiguration sslConfig = ssl.createSslConfiguration(); listener.setSslConfiguration(sslConfig); listener.setImplicitSsl(true); DataConnectionConfigurationFactory dataConfigFactory = new DataConnectionConfigurationFactory(); dataConfigFactory.setImplicitSsl(true); listener.setDataConnectionConfiguration(dataConfigFactory.createDataConnectionConfiguration()); return listener; }
Example #2
Source File: FtpsProvider.java From product-ei with Apache License 2.0 | 5 votes |
/** * Creates and starts an embedded Apache FTPS Server (MINA). * * @throws FtpException * @throws IOException */ static void startFtpsServer() throws FtpException, IOException { if (Server != null) { return; } init(); final FtpServerFactory serverFactory = new FtpServerFactory(); final PropertiesUserManagerFactory propertiesUserManagerFactory = new PropertiesUserManagerFactory(); final URL userPropsResource = ClassLoader.getSystemClassLoader().getResource(USER_PROPS_RES); Assert.assertNotNull(USER_PROPS_RES, userPropsResource); propertiesUserManagerFactory.setUrl(userPropsResource); final UserManager userManager = propertiesUserManagerFactory.createUserManager(); serverFactory.setUserManager(userManager); final ListenerFactory factory = new ListenerFactory(); // set the port of the listener factory.setPort(SocketPort); // define SSL configuration final URL serverJksResource = ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES); Assert.assertNotNull(SERVER_JKS_RES, serverJksResource); final SslConfigurationFactory ssl = new SslConfigurationFactory(); final File keyStoreFile = FileUtils.toFile(serverJksResource); Assert.assertTrue(keyStoreFile.toString(), keyStoreFile.exists()); ssl.setKeystoreFile(keyStoreFile); ssl.setKeystorePassword(Constants.KEYSTORE_PASSWORD); factory.setSslConfiguration(ssl.createSslConfiguration()); serverFactory.addListener("default", factory.createListener()); // start the server Server = serverFactory.createServer(); Server.start(); }
Example #3
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 #4
Source File: AbstractFtpsProviderTestCase.java From commons-vfs with Apache License 2.0 | 4 votes |
/** * Creates and starts an embedded Apache FTP Server (MINA). * * @param implicit FTPS connection mode * @throws FtpException * @throws IOException */ static void setUpClass(final boolean implicit) throws FtpException, IOException { if (Server != null) { return; } init(); final FtpServerFactory serverFactory = new FtpServerFactory(); final PropertiesUserManagerFactory propertiesUserManagerFactory = new PropertiesUserManagerFactory(); final URL userPropsResource = ClassLoader.getSystemClassLoader().getResource(USER_PROPS_RES); Assert.assertNotNull(USER_PROPS_RES, userPropsResource); propertiesUserManagerFactory.setUrl(userPropsResource); final UserManager userManager = propertiesUserManagerFactory.createUserManager(); final BaseUser user = (BaseUser) userManager.getUserByName("test"); // Pickup the home dir value at runtime even though we have it set in the user prop file // The user prop file requires the "homedirectory" to be set user.setHomeDirectory(getTestDirectory()); serverFactory.setUserManager(userManager); final ListenerFactory factory = new ListenerFactory(); // set the port of the listener factory.setPort(SocketPort); // define SSL configuration final URL serverJksResource = ClassLoader.getSystemClassLoader().getResource(SERVER_JKS_RES); Assert.assertNotNull(SERVER_JKS_RES, serverJksResource); final SslConfigurationFactory ssl = new SslConfigurationFactory(); final File keyStoreFile = FileUtils.toFile(serverJksResource); Assert.assertTrue(keyStoreFile.toString(), keyStoreFile.exists()); ssl.setKeystoreFile(keyStoreFile); ssl.setKeystorePassword("password"); // set the SSL configuration for the listener factory.setSslConfiguration(ssl.createSslConfiguration()); factory.setImplicitSsl(implicit); // replace the default listener serverFactory.addListener("default", factory.createListener()); // start the server Server = serverFactory.createServer(); Server.start(); }