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


Java BaseUser类代码示例

本文整理汇总了Java中org.apache.ftpserver.usermanager.impl.BaseUser的典型用法代码示例。如果您正苦于以下问题:Java BaseUser类的具体用法?Java BaseUser怎么用?Java BaseUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BaseUser类属于org.apache.ftpserver.usermanager.impl包,在下文中一共展示了BaseUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的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: addUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
public void addUser(String name, String pass, String directory, boolean canWrite) {
    BaseUser user = new BaseUser();
    user.setName(name);
    user.setPassword(pass);

    //String root = ProjectManager.getInstance().getCurrentProject().getStoragePath() + "/" + directory;
    user.setHomeDirectory(directory);

    //check if user can write
    if (canWrite) {
        List<Authority> auths = new ArrayList<Authority>();
        Authority auth = new WritePermission();
        auths.add(auth);
        user.setAuthorities(auths);
    }

    try {
        um.save(user);
    } catch (FtpException e) {
        e.printStackTrace();
    }

}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:24,代码来源:PFtpServer.java

示例3: setUp

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的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

示例4: create

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
public User create() {
    BaseUser user = new BaseUser();
    user.setEnabled(mEnable);
    user.setHomeDirectory(mHomeDirectory);
    user.setMaxIdleTime(mIdleSec);
    user.setName(mName);
    if (!TextUtils.isEmpty(mPassword))
        user.setPassword(mPassword);
    final ArrayList<Authority> authorities = new ArrayList<>();
    if (mHasWritePermission)
        authorities.add(new WritePermission());
    authorities.add(new TransferRatePermission(mMaxDownloadRate, mMaxUploadRate));
    authorities.add(new ConcurrentLoginPermission(mMaxConcurrentLogin,
            mMaxConcurrentLoginPerIP));
    user.setAuthorities(authorities);
    return user;
}
 
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:18,代码来源:FTPUser.java

示例5: setupFTPServer

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
@BeforeClass
public static void setupFTPServer() throws Exception
{
    FtpServerFactory serverFactory = new FtpServerFactory();

    ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
    connectionConfigFactory.setAnonymousLoginEnabled(true);

    serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());

    BaseUser user = new BaseUser();
    user.setHomeDirectory(Paths.get(FSBuilder.DIR_FOR_TEST_TREE).toAbsolutePath().toString());
    user.setName("anonymous");
    serverFactory.getUserManager().save(user);

    ListenerFactory factory = new ListenerFactory();
    factory.setPort(2221);
    serverFactory.addListener("default", factory.createListener());
    server = serverFactory.createServer();
    server.start();
}
 
开发者ID:anstarovoyt,项目名称:jb-filemanager,代码行数:22,代码来源:FTPSourceTest.java

示例6: setUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的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

示例7: setUp

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    BaseUser baseUser = new BaseUser();
    baseUser.setHomeDirectory(ROOT_DIR.getAbsolutePath());
    fileSystemView = new NativeFileSystemView(baseUser) {
    };
    directoryLister = new DirectoryLister();

    assertTrue(ROOT_DIR.mkdirs());
    assertTrue(TEST_DIR1.mkdirs());
    assertTrue(TEST_DIR2.mkdirs());
    TestUtil.writeDataToFile(TEST_FILE1, TEST_DATA);
    TestUtil.writeDataToFile(TEST_FILE1_IN_DIR1, TEST_DATA);
    TEST_FILE2_IN_DIR1.createNewFile();
    assertTrue(TEST_DIR_IN_DIR1.mkdir());
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:17,代码来源:DirectoryListerTest.java

示例8: getUserByName

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
@Override
public User getUserByName(final String name) throws FtpException
{
   if (name == null) return null;
   fr.gael.dhus.database.object.User u = userService.getUserNoCheck (name);
   
   if (u==null) return null;
   
   BaseUser user = new BaseUser();
   user.setName(u.getUsername());
   user.setPassword(u.getPassword());
   
   user.setEnabled(
      u.isEnabled()               && 
      u.isAccountNonExpired()     &&
      u.isAccountNonLocked()      &&
      u.isCredentialsNonExpired() &&
      !u.isDeleted());
   
   user.setHomeDirectory("/");
   List<Authority> authorities = new ArrayList<>();
   authorities.add(new WritePermission ());
   // No special limit
   int maxLogin = 0;
   int maxLoginPerIP = 0;
   authorities.add(new ConcurrentLoginPermission(maxLogin, maxLoginPerIP));
   int uploadRate = 0;
   int downloadRate = 0;
   authorities.add(new TransferRatePermission(downloadRate, uploadRate));
   user.setAuthorities(authorities);
   user.setMaxIdleTime(1000);
   return user;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:34,代码来源:DHuSFtpUserManager.java

示例9: TestUserManager

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
private TestUserManager(String homeDirectory) {
	this.testUser = new BaseUser();
	this.testUser.setAuthorities(Arrays.asList(new ConcurrentLoginPermission(1024, 1024),
			new WritePermission(),
			new TransferRatePermission(1024, 1024)));
	this.testUser.setHomeDirectory(homeDirectory);
	this.testUser.setName("TEST_USER");
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:ftp,代码行数:9,代码来源:FtpTestSupport.java

示例10: setUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
/**
 * Sets the user.
 *
 * @param _user the new user
 */
public void setUser(BaseUser _user){
	user = _user;
	if(user.getAuthorities() == null || user.getAuthorities().isEmpty()){
		List<Authority> authorities = new ArrayList<Authority>();
		authorities.add(new WritePermission());
		authorities.add(new ConcurrentLoginPermission(10, 10));
		user.setAuthorities(authorities);
	}
}
 
开发者ID:dubasdey,项目名称:portable-ftp-server,代码行数:15,代码来源:InMemoryUserManager.java

示例11: setUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
/**
 * Sets the user.
 *
 * @param login the login
 * @param password the password
 * @param home the home
 */
public void setUser(String login,char[] password,String home){
	BaseUser user = new BaseUser();
    user.setName(login);
    if(password !=null && password.length>0){
    	user.setPassword(new String(password));
    }
    user.setHomeDirectory(home);
    user.setEnabled(true);
    userManager.setUser(user);
}
 
开发者ID:dubasdey,项目名称:portable-ftp-server,代码行数:18,代码来源:FTPServer.java

示例12: InMemoryUserManagerTest

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
/**
 * Instantiates a new in memory user manager test.
 */
public InMemoryUserManagerTest(){
	imum = new InMemoryUserManager();
	
	BaseUser user = new BaseUser();
    user.setName(USER);
    user.setPassword(USER);
    user.setEnabled(true);
	imum.setUser(user);
}
 
开发者ID:dubasdey,项目名称:portable-ftp-server,代码行数:13,代码来源:InMemoryUserManagerTest.java

示例13: saveIgnoredTEst

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
/**
 * Save ignored T est.
 *
 * @throws FtpException the ftp exception
 */
@Test
public void saveIgnoredTEst() throws FtpException{
	BaseUser user = new BaseUser();
    user.setName("admin2");
    user.setPassword(USER);
    user.setEnabled(true);
	imum.save(user);
	
	User u1 = imum.getUserByName("admin2");
	assertNotNull(u1);
	assertEquals(USER,u1.getName());
}
 
开发者ID:dubasdey,项目名称:portable-ftp-server,代码行数:18,代码来源:InMemoryUserManagerTest.java

示例14: configureAnonymousLogin

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
private void configureAnonymousLogin(String octopusHome) throws FtpException
{
	connectionConfigFactory.setAnonymousLoginEnabled(true);
	serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());

	BaseUser user = configureAnonymousUser();

	Path path = Paths.get(octopusHome, "projects");
	String homeDirectory = path.toString();
	user.setHomeDirectory(homeDirectory);
	serverFactory.getUserManager().save(user);
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:13,代码来源:OctopusFTPServer.java

示例15: configureAnonymousUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入依赖的package包/类
private BaseUser configureAnonymousUser()
{
	BaseUser user = new BaseUser();
	user.setName("anonymous");
	List<Authority> auths = new ArrayList<Authority>();
	Authority auth = new WritePermission();
	auths.add(auth);
	user.setAuthorities(auths);
	return user;
}
 
开发者ID:octopus-platform,项目名称:bjoern,代码行数:11,代码来源:OctopusFTPServer.java


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