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


Java BaseUser.setMaxIdleTime方法代码示例

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


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

示例1: 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

示例2: 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

示例3: createUserManager

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private InMemoryUserManager createUserManager() throws FtpException {
    InMemoryUserManager userManager = new InMemoryUserManager();
    for (FtpUser user : configuration.users()) {
        BaseUser baseUser = new BaseUser();
        baseUser.setName(user.login);
        baseUser.setPassword(user.password);
        baseUser.setMaxIdleTime(0);
        baseUser.setHomeDirectory(userHomeCreator.createUserHome(user.login).getAbsolutePath());
        baseUser.setEnabled(true);

        baseUser.setAuthorities(createAuthorities());
        userManager.save(baseUser);
    }
    return userManager;
}
 
开发者ID:signed,项目名称:in-memory-infrastructure,代码行数:16,代码来源:FtpServer.java

示例4: getUserByName

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
 * Load user data.
 */
public User getUserByName(String userName) {
    if (!doesExist(userName)) {
        return null;
    }

    String baseKey = PREFIX + userName + '.';
    BaseUser user = new BaseUser();
    user.setName(userName);
    user.setEnabled(userDataProp.getBoolean(baseKey + ATTR_ENABLE, true));
    user.setHomeDirectory(userDataProp
            .getProperty(baseKey + ATTR_HOME, "/"));

    List<Authority> authorities = new ArrayList<Authority>();

    if (userDataProp.getBoolean(baseKey + ATTR_WRITE_PERM, false)) {
        authorities.add(new WritePermission());
    }

    int maxLogin = userDataProp.getInteger(baseKey + ATTR_MAX_LOGIN_NUMBER,
            0);
    int maxLoginPerIP = userDataProp.getInteger(baseKey
            + ATTR_MAX_LOGIN_PER_IP, 0);

    authorities.add(new ConcurrentLoginPermission(maxLogin, maxLoginPerIP));

    int uploadRate = userDataProp.getInteger(
            baseKey + ATTR_MAX_UPLOAD_RATE, 0);
    int downloadRate = userDataProp.getInteger(baseKey
            + ATTR_MAX_DOWNLOAD_RATE, 0);

    authorities.add(new TransferRatePermission(downloadRate, uploadRate));

    user.setAuthorities(authorities);

    user.setMaxIdleTime(userDataProp.getInteger(baseKey
            + ATTR_MAX_IDLE_TIME, 0));

    return user;
}
 
开发者ID:lgnlgn,项目名称:feluca,代码行数:43,代码来源:PropertiesUserManager.java

示例5: createUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
 * Creates a user based on the configuration set on the factory
 * @return The created user
 */
public User createUser() {
	BaseUser user = new BaseUser();
	user.setName(name);
	user.setPassword(password);
	user.setHomeDirectory(homeDir);
	user.setEnabled(isEnabled);
	user.setAuthorities(authorities);
	user.setMaxIdleTime(maxIdleTimeSec);
	
	return user;
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:16,代码来源:UserFactory.java

示例6: createDefaultUsers

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
 * Create default users.
 */
public void createDefaultUsers() throws Exception {
    UserManager userManager = getUserManager();

    // create admin user
    String adminName = userManager.getAdminName();
    if (!userManager.doesExist(adminName)) {
        LOG.info("Creating user : " + adminName);
        BaseUser adminUser = new BaseUser();
        adminUser.setName(adminName);
        adminUser.setPassword(adminName);
        adminUser.setEnabled(true);

        adminUser.setAuthorities(ADMIN_AUTHORITIES);

        adminUser.setHomeDirectory("./res/home");
        adminUser.setMaxIdleTime(0);
        userManager.save(adminUser);
    }

    // create anonymous user
    if (!userManager.doesExist("anonymous")) {
        LOG.info("Creating user : anonymous");
        BaseUser anonUser = new BaseUser();
        anonUser.setName("anonymous");
        anonUser.setPassword("");

        anonUser.setAuthorities(ANON_AUTHORITIES);

        anonUser.setEnabled(true);

        anonUser.setHomeDirectory("./res/home");
        anonUser.setMaxIdleTime(300);
        userManager.save(anonUser);
    }
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:39,代码来源:DefaultFtpServerContext.java

示例7: loadUser

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private BaseUser loadUser(String suffix, String defaultUser, String defaultPassword) {
	final String username = configuration.getProperty("ftp.user"+suffix, defaultUser);
	final String password = configuration.getProperty("ftp.pass"+suffix, defaultPassword);
	if (StringUtils.isBlank(username) || StringUtils.isBlank(password)){
		return null;
	}
	BaseUser user = new BaseUser();
	user.setEnabled(true);
	user.setHomeDirectory(configuration.getProperty("ftp.home"+suffix, ""));
	user.setMaxIdleTime(300);
	user.setName(username);
	user.setPassword(password);
	List<Authority> authorities = new ArrayList<>();
	final String rights = configuration.getProperty("ftp.rights"+suffix,"pwd|cd|dir|put|get|rename|delete|mkdir|rmdir|append");
	if (rights.contains("pwd")){
		authorities.add(new PWDPermission());
	}
	if (rights.contains("cd")){
		authorities.add(new CWDPermission());
	}
	if (rights.contains("dir")){
		authorities.add(new ListPermission());
	}
	if (rights.contains("put")){
		authorities.add(new StorePermission());
	}
	if (rights.contains("get")){
		authorities.add(new RetrievePermission());
	}
	if (rights.contains("rename")){
		authorities.add(new RenameToPermission());
	}
	if (rights.contains("delete")){
		authorities.add(new DeletePermission());
	}
	if (rights.contains("rmdir")){
		authorities.add(new RemoveDirPermission());
	}
	if (rights.contains("mkdir")){
		authorities.add(new MakeDirPermission());
	}
	if (rights.contains("append")){
		authorities.add(new AppendPermission());
	}
	
	authorities.add(new WritePermission());
	authorities.add(new ConcurrentLoginPermission(10, 5));
	user.setAuthorities(authorities);
	LOG.info("FTP User Manager configured for user '" + user.getName() + "'");
	LOG.info("FTP rights '" + rights + "'");
	return user;
}
 
开发者ID:andresoviedo,项目名称:google-drive-ftp-adapter,代码行数:53,代码来源:GFtpServerFactory.java

示例8: main

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
 * Used to add users to the user manager for a particular FtpServer configuration
 * 
 * @param args
 *            The first element of this array must specify the kind of
 *            configuration to be used to start the server.
 */
public static void main(String args[]) {
    AddUser addUser = new AddUser();
    
    try {

        // get configuration
        FtpServer server = addUser.getConfiguration(args);
        if (server == null) {
            return;
        } 
        
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        UserManager um = ((DefaultFtpServer)server).getUserManager();
        
        BaseUser user = new BaseUser();

        System.out.println("Asking for details of the new user");
        
        System.out.println();
        String userName = askForString(in, "User name:", "User name is mandatory");
        if(userName == null) {
            return;
        }
        user.setName(userName);
        
        user.setPassword(askForString(in, "Password:"));
        
        String home = askForString(in, "Home directory:", "Home directory is mandatory");
        if(home == null) {
            return;            
        }
        user.setHomeDirectory(home);
        
        user.setEnabled(askForBoolean(in, "Enabled (Y/N):"));

        user.setMaxIdleTime(askForInt(in, "Max idle time in seconds (0 for none):"));
        
        List<Authority> authorities = new ArrayList<Authority>();
        
        if(askForBoolean(in, "Write permission (Y/N):")) {
            authorities.add(new WritePermission());
        }

        int maxLogins = askForInt(in, "Maximum number of concurrent logins (0 for no restriction)");
        int maxLoginsPerIp = askForInt(in, "Maximum number of concurrent logins per IP (0 for no restriction)");
        
        authorities.add(new ConcurrentLoginPermission(maxLogins, maxLoginsPerIp));
        
        int downloadRate = askForInt(in, "Maximum download rate (0 for no restriction)");
        int uploadRate = askForInt(in, "Maximum upload rate (0 for no restriction)");
        
        authorities.add(new TransferRatePermission(downloadRate, uploadRate));
        
        user.setAuthorities(authorities);
        
        um.save(user);
        
        if(um instanceof PropertiesUserManager) {
            File file = ((PropertiesUserManager) um).getFile();
            
            if(file != null) {
                System.out.println("User saved to file: " + file.getAbsolutePath());
            } else {
                System.err.println("User manager does not have a file configured, will not save user to file");
            }
        } else {
            System.out.println("User saved");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:82,代码来源:AddUser.java


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