Java Code Examples for org.apache.ftpserver.ftplet.UserManager#getUserByName()
The following examples show how to use
org.apache.ftpserver.ftplet.UserManager#getUserByName() .
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: FtpProviderTestCase.java From commons-vfs with Apache License 2.0 | 5 votes |
/** * Creates and starts an embedded Apache FTP Server (MINA). * * @param rootDirectory the local FTP server rootDirectory * @param fileSystemFactory optional local FTP server FileSystemFactory * @throws FtpException * @throws IOException */ static void setUpClass(final String rootDirectory, final FileSystemFactory fileSystemFactory) 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(rootDirectory); userManager.save(user); serverFactory.setUserManager(userManager); if (fileSystemFactory != null) { serverFactory.setFileSystem(fileSystemFactory); } final ListenerFactory factory = new ListenerFactory(); // set the port of the listener factory.setPort(SocketPort); // replace the default listener serverFactory.addListener("default", factory.createListener()); // start the server Server = serverFactory.createServer(); Server.start(); }
Example 2
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(); }