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


Java TransferRatePermission类代码示例

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


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

示例1: create

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

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

示例4: createAuthorities

import org.apache.ftpserver.usermanager.impl.TransferRatePermission; //导入依赖的package包/类
private List<Authority> createAuthorities() {
    List<Authority> authorities = new ArrayList<Authority>();
    authorities.add(new ConcurrentLoginPermission(0, 0));
    authorities.add(new WritePermission());
    authorities.add(new TransferRatePermission(0, 0));
    return authorities;
}
 
开发者ID:signed,项目名称:in-memory-infrastructure,代码行数:8,代码来源:FtpServer.java

示例5: getUserByName

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

示例6: main

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