本文整理汇总了Java中org.apache.ftpserver.ftplet.UserManager类的典型用法代码示例。如果您正苦于以下问题:Java UserManager类的具体用法?Java UserManager怎么用?Java UserManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserManager类属于org.apache.ftpserver.ftplet包,在下文中一共展示了UserManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
@BeforeClass
public static void start() throws Exception {
final FtpServerFactory serverFactory = new FtpServerFactory();
final PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setUrl(ConcurrentTransferWorkerTest.class.getResource("/ftpserver-user.properties"));
final UserManager userManager = userManagerFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("test");
user.setPassword("test");
user.setHomeDirectory(new TemporaryApplicationResourcesFinder().find().getAbsolute());
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
authorities.add(new ConcurrentLoginPermission(2, Integer.MAX_VALUE));
user.setAuthorities(authorities);
userManager.save(user);
serverFactory.setUserManager(userManager);
final ListenerFactory factory = new ListenerFactory();
factory.setPort(PORT_NUMBER);
serverFactory.addListener("default", factory.createListener());
server = serverFactory.createServer();
server.start();
}
示例2: initFtpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
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();
}
示例3: initFtpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
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();
}
示例4: createFtpServerFactory
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
protected FtpServerFactory createFtpServerFactory() throws Exception {
assertTrue(USERS_FILE.exists());
assertTrue("Port number is not initialized in an expected range: " + BaseServerTestSupport.port, BaseServerTestSupport.port >= 21000);
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
pumf.setAdminName("admin");
pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
pumf.setFile(USERS_FILE);
UserManager userMgr = pumf.createUserManager();
ListenerFactory factory = new ListenerFactory();
factory.setPort(BaseServerTestSupport.port);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userMgr);
serverFactory.setFileSystem(fsf);
serverFactory.setConnectionConfig(new ConnectionConfigFactory().createConnectionConfig());
serverFactory.addListener(DEFAULT_LISTENER, factory.createListener());
return serverFactory;
}
示例5: amqpReplyFlow
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
@Bean
IntegrationFlow amqpReplyFlow(ConnectionFactory rabbitConnectionFactory,
UserManager ftpUserManager) {
return IntegrationFlows.from(Amqp.inboundGateway(rabbitConnectionFactory, this.ftpRequests)
.messageConverter(new Jackson2JsonMessageConverter()))
.transform(String.class, new GenericTransformer<String, String>() {
@Override
public String transform(String source) {
try {
Map<String, String> map = toMap(source);
String ws = map.get("workspace");
String usr = map.get("user");
String password = UUID.randomUUID().toString();
FtpUser user = new FtpUser(ws, usr, password, true);
ftpUserManager.save(user);
String ftpUri = buildFtpConnectionString(host, port, user);
log.info("registering: workspace: " + ws + ", " + "user: " + usr + ", ftp URI: " + ftpUri);
return ftpUri;
} catch (FtpException e) {
throw new RuntimeException(e);
}
}
}).get();
}
示例6: initFtpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
public static void initFtpServer() throws Exception {
FtpServerFactory serverFactory = new FtpServerFactory();
// setup user management to read our users.properties and use clear text passwords
URL url = ObjectHelper.loadResourceAsURL("users.properties");
UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), url, "admin");
serverFactory.setUserManager(uman);
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
factory.setPort(port);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
}
示例7: initFtpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
public void initFtpServer() throws Exception {
FtpServerFactory serverFactory = new FtpServerFactory();
// setup user management to read our users.properties and use clear text passwords
URL url = ObjectHelper.loadResourceAsURL("users.properties");
UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), url, "admin");
serverFactory.setUserManager(uman);
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
factory.setPort(port);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
}
示例8: setUp
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
/**
* Sets up Apache FTP server.
*
* @throws Exception When it fails.
*/
@Before
public void setUp() throws Exception {
final UserManager manager = new PropertiesUserManagerFactory()
.createUserManager();
final BaseUser user = new BaseUser();
final ListenerFactory listener = new ListenerFactory();
final FtpServerFactory factory = new FtpServerFactory();
user.setName(NAME);
user.setPassword(PASS);
user.setHomeDirectory(TEMP_DIR);
manager.save(user);
listener.setPort(PORT);
factory.setUserManager(manager);
factory.addListener("default", listener.createListener());
this.server = factory.createServer();
this.server.start();
Files.deleteIfExists(TEMP);
}
示例9: setUser
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
public UserManager setUser() {
BaseUser user = new BaseUser();
user.setName(userName);
user.setPassword(password);
user.setHomeDirectory(homeDirectory);
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
user.setAuthorities(authorities);
UserManager um = userManagerFactory.createUserManager();
try {
um.save(user);//Save the user to the user list on the filesystem
} catch (FtpException e1) {
log.error("FTP server startup failed " + e1.getMessage());
}
return um;
}
示例10: Ftp
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
public Ftp(int port, UserManager userManager, Ftplet ftplet) {
LOG.info("Starting up internal FTP server on port :" + port + "...");
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(port);
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.addListener("default", listenerFactory.createListener());
serverFactory.setFtplets(Collections.singletonMap("security", ftplet));
serverFactory.setUserManager(userManager);
server = serverFactory.createServer();
try {
server.start();
LOG.info("Internal FTP server started OK...");
} catch (FtpException e) {
LOG.error("FTP server failed to start, snapshots from cameras won't be processed.", e);
}
}
示例11: createServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的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();
}
示例12: initFtpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
public static void initFtpServer() throws Exception {
FtpServerFactory serverFactory = new FtpServerFactory();
// setup user management to read our users.properties and use clear text
// passwords
URL url = ObjectHelper.loadResourceAsURL("users.properties");
UserManager uman = new PropertiesUserManager(new ClearTextPasswordEncryptor(), url, "admin");
serverFactory.setUserManager(uman);
NativeFileSystemFactory fsf = new NativeFileSystemFactory();
fsf.setCreateHome(true);
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
factory.setPort(port);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
}
示例13: startServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的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);
}
}
示例14: ftpServer
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的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();
}
示例15: registerFtpUser
import org.apache.ftpserver.ftplet.UserManager; //导入依赖的package包/类
/**
* @param aUsername
* @param aPassword
* @throws FtpException
*/
private void registerFtpUser( String aUsername, String aPassword ) throws FtpException
{
BaseUser user = new BaseUser();
user.setName( aUsername );
user.setPassword( aPassword );
user.setAuthorities(myFtpAuthorities);
UserManager userManager = myServerFactory.getUserManager();
userManager.save(user);
}