当前位置: 首页>>代码示例>>Java>>正文


Java UserManager类代码示例

本文整理汇总了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();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:23,代码来源:ConcurrentTransferWorkerTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:FtpCronScheduledRoutePolicyTest.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:FtpServerTestSupport.java

示例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();
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:25,代码来源:Application.java

示例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();
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:FtpServerBean.java

示例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();
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:FtpServerBean.java

示例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);
}
 
开发者ID:piotrkot,项目名称:ftp-wrapper,代码行数:24,代码来源:FTPIntegrationTest.java

示例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;
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:17,代码来源:FTPServerManager.java

示例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);
}
   }
 
开发者ID:PoJD,项目名称:hawa,代码行数:19,代码来源:Ftp.java

示例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();
}
 
开发者ID:tadayosi,项目名称:samples-switchyard,代码行数:18,代码来源:FTPServer.java

示例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();
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:21,代码来源:FtpServerBean.java

示例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);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:30,代码来源:TestFTPFileSystem.java

示例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();
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:9,代码来源:FtpServerConfiguration.java

示例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);
}
 
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:15,代码来源:FtpExecutorTest.java


注:本文中的org.apache.ftpserver.ftplet.UserManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。