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


Java Authority类代码示例

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


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

示例1: start

import org.apache.ftpserver.ftplet.Authority; //导入依赖的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.ftplet.Authority; //导入依赖的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: from

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
static FTPUser from(User user) {
    final String name = user.getName();
    final String password = user.getPassword();
    final String homeDirectory = user.getHomeDirectory();
    final boolean enable = user.getEnabled();
    final int idleSec = user.getMaxIdleTime();
    boolean hasWritePermission = false;
    List<? extends Authority> authorities = user.getAuthorities();
    if (authorities != null) {
        for (Authority authority : authorities) {
            if (authority instanceof WritePermission) {
                hasWritePermission = true;
                break;
            }
        }
    }
    return new FTPUser(name, password, homeDirectory, false,
            enable, idleSec, hasWritePermission,
            0, 0, 10, 10);
}
 
开发者ID:AlexMofer,项目名称:ProjectX,代码行数:21,代码来源:FTPUser.java

示例4: create

import org.apache.ftpserver.ftplet.Authority; //导入依赖的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: setUser

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

示例6: addUser

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
public FtpServerBuilder addUser(final String username, final String password, final File home, final boolean write) throws FtpException {
    UserFactory userFactory = new UserFactory();
    userFactory.setHomeDirectory(home.getAbsolutePath());
    userFactory.setName(username);
    userFactory.setPassword(password);

    if (write) {
        List<Authority> authorities = new ArrayList<Authority>();
        Authority writePermission = new WritePermission();
        authorities.add(writePermission);
        userFactory.setAuthorities(authorities);
    }
    User user = userFactory.createUser();
    ftpServerFactory.getUserManager().save(user);

    return this;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:18,代码来源:CamelFtpBaseTest.java

示例7: getUserByName

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

示例8: setUser

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

示例9: startServer

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

示例10: configureAnonymousUser

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

示例11: getAuthorities

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
@Override
public List<Authority> getAuthorities() {
    List<Authority> authorities = new ArrayList<>();
    authorities.addAll(this.anonAuthorities);
    if (this.admin) {
        authorities.addAll(this.adminAuthorities);
    }
    return authorities;
}
 
开发者ID:joshlong,项目名称:cloudfoundry-ftp-service-broker,代码行数:10,代码来源:FtpUser.java

示例12: setUpStatic

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpStatic() throws Exception
{
    myTargetDirLocal = new File( TEST_TARGET_DIR_LOCAL ).getCanonicalPath() + File.separator;
    myFtpAuthorities = new ArrayList<Authority>();
    myFtpAuthorities.add(new WritePermission());
}
 
开发者ID:heribender,项目名称:SocialDataImporter,代码行数:11,代码来源:FtpExecutorTest.java

示例13: createAuthorities

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

示例14: setFtpEnv

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
private void setFtpEnv() {
	serverFactory = new FtpServerFactory();
	factory = new ListenerFactory();

	// set the port of the listener
	factory.setPort(port);

	// define SSL configuration
	// SslConfigurationFactory ssl = new SslConfigurationFactory();
	// ssl.setKeystoreFile(new File("ftpserver.jks"));
	// ssl.setKeystorePassword("password");

	// set the SSL configuration for the listener
	// factory.setSslConfiguration(ssl.createSslConfiguration());
	// factory.setImplicitSsl(true);

	// replace the default listener
	serverFactory.addListener("default", factory.createListener());

	List<Authority> auths = new ArrayList<Authority>();
	Authority auth = new WritePermission();
	auths.add(auth);

	try {
		appendUser("peerless", "peerless", "ftphome", true, auths);
		appendUser("hwlee", "hwlee", "ftphome", true, auths);
	} catch (FtpException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

	/*
	 * user.setName("hwlee"); user.setPassword("hwlee");
	 * user.setHomeDirectory("ftphome"); user.setEnabled(true);
	 * user.setAuthorities(auths);
	 */

	serverFactory.setUserManager(userManagerFactory.createUserManager());
	server = serverFactory.createServer();
}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:41,代码来源:PeerlessFtpServerSupport.java

示例15: appendUser

import org.apache.ftpserver.ftplet.Authority; //导入依赖的package包/类
private void appendUser(String name, String passwd, String homedir,
		Boolean enabled, List<Authority> auths) throws FtpException {
	user.setName(name);
	user.setPassword(passwd);
	user.setHomeDirectory(homedir);
	user.setEnabled(enabled);
	user.setAuthorities(auths);
	um.save(user);
}
 
开发者ID:knowpd,项目名称:p2p-file-sharing-system,代码行数:10,代码来源:PeerlessFtpServerSupport.java


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