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


Java BaseUser.setAuthorities方法代码示例

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


在下文中一共展示了BaseUser.setAuthorities方法的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: 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

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

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

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

示例7: registerFtpUser

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

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

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

示例10: createServer

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
private FtpServer createServer( int port, String username, String password, boolean implicitSsl ) throws Exception {
  ListenerFactory factory = new ListenerFactory();
  factory.setPort( port );

  if ( implicitSsl ) {
    SslConfigurationFactory ssl = new SslConfigurationFactory();
    ssl.setKeystoreFile( new File( SERVER_KEYSTORE ) );
    ssl.setKeystorePassword( PASSWORD );
    // set the SSL configuration for the listener
    factory.setSslConfiguration( ssl.createSslConfiguration() );
    factory.setImplicitSsl( true );
  }

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

  PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();

  userManagerFactory.setFile( new File( SERVER_USERS ) );
  UserManager userManager = userManagerFactory.createUserManager();
  if ( !userManager.doesExist( username ) ) {
    BaseUser user = new BaseUser();
    user.setName( username );
    user.setPassword( password );
    user.setEnabled( true );
    user.setHomeDirectory( USER_HOME_DIR );
    user.setAuthorities( Collections.<Authority>singletonList( new WritePermission() ) );
    userManager.save( user );
  }

  serverFactory.setUserManager( userManager );
  return serverFactory.createServer();
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:35,代码来源:FtpsServer.java

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

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

示例13: setUp

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {

   if (ftpHomeDirFile.getParentFile().exists()) {
      IOHelper.deleteFile(ftpHomeDirFile.getParentFile());
   }
   ftpHomeDirFile.mkdirs();
   ftpHomeDirFile.getParentFile().deleteOnExit();

   FtpServerFactory serverFactory = new FtpServerFactory();
   ListenerFactory factory = new ListenerFactory();

   PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
   UserManager userManager = userManagerFactory.createUserManager();

   BaseUser user = new BaseUser();
   user.setName("activemq");
   user.setPassword("activemq");
   user.setHomeDirectory(ftpHomeDirFile.getParent());

   // authorize user
   List<Authority> auths = new ArrayList<>();
   Authority auth = new WritePermission();
   auths.add(auth);
   user.setAuthorities(auths);

   userManager.save(user);

   BaseUser guest = new BaseUser();
   guest.setName("guest");
   guest.setPassword("guest");
   guest.setHomeDirectory(ftpHomeDirFile.getParent());

   userManager.save(guest);

   serverFactory.setUserManager(userManager);
   factory.setPort(0);
   serverFactory.addListener(ftpServerListenerName, factory.createListener());
   server = serverFactory.createServer();
   server.start();
   ftpPort = serverFactory.getListener(ftpServerListenerName).getPort();
   super.setUp();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:44,代码来源:FTPTestSupport.java

示例14: createOnTheFlyFTPConfiguration

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
  * Create
  * @param vmiName The name of the VMI
  * @param vmiFileName The filename of the VMI (to be uploaded or retrieved)
  * @param type The type of connection (upload, download) (@see FTPSession)
  * @return
  */
 public FTPTransferParams createOnTheFlyFTPConfiguration(String vmiName, String vmiFileName, int type) throws FtpException{
  log.debug("Creating on-the-fly FTP configuration");
  FTPTransferParams tp = new FTPTransferParams();
  BaseUser user = new BaseUser();
  String filePath, msg;
  String newUser = selectNewUser();
  if (newUser == null) {
	  msg = "Error creating new user.";
	  log.error(msg);
	  throw new FtpException(msg);
	}
  
// Create a temporary user in the FTP server.
  user.setName(newUser);
  String newPassword = VMRCServerUtils.generateRandomChain(8);
  user.setPassword(newPassword);
  
 
  if (type == FTPSession.TYPE_UPLOAD){	  
	filePath = RepositoryManager.getRepositoryLocationToStoreFile(vmiName, vmiFileName);
	log.debug("Creating the appropriate dirs to host file: " + vmiFileName);
	new File(filePath).getParentFile().mkdirs();
	user.setHomeDirectory(new File(filePath).getParent());
	List<Authority> auths = new ArrayList<Authority>();
	Authority auth = new WritePermission();
	auths.add(auth);
	user.setAuthorities(auths);
  } else{ //DOWNLOAD
	  String[] files = VMRCServerUtils.listDirectory(RepositoryManager.getRepositoryLocationForVMI(vmiName)); 
	  if (files == null){				  
		  msg = "No file in the repository found for VMI " + vmiName;
		  log.error(msg);
		  throw new FtpException(msg);		  
	  }
	  log.debug("Found " + files.length + " related to " + vmiName + " in the repository. Will pick the first one.");
	  filePath = RepositoryManager.getRepositoryLocationToStoreFile(vmiName,files[0]); 
	  log.debug("Obtained file " + filePath);
  }
  				 
    try {
      // Store the user into users.properties file
      userManager.save(user);
	} catch (FtpException e) {
	   deleteNewUser(newUser);			   
    }
  
	tp.setUser(newUser);
    tp.setPass(newPassword);
    tp.setPath(filePath);
    tp.setHost(this.host);
    tp.setPort(DEFAULT_FTP_PORT);
  return tp;
 }
 
开发者ID:grycap,项目名称:vmrc,代码行数:61,代码来源:FTPServer.java

示例15: createOnTheFlyFTPConfiguration

import org.apache.ftpserver.usermanager.impl.BaseUser; //导入方法依赖的package包/类
/**
  * Create
  * @param vmiName The name of the VMI
  * @param vmiFileName The filename of the VMI (to be uploaded or retrieved)
  * @param type The type of connection (upload, download) (@see FTPSession)
  * @return
  */
 public FTPTransferParams createOnTheFlyFTPConfiguration(String vmiName, String vmiFileName, int type) throws FtpException{
  log.debug("Creating on-the-fly FTP configuration");
  FTPTransferParams tp = new FTPTransferParams();
  BaseUser user = new BaseUser();
  String filePath, msg;
  String newUser = selectNewUser();
  if (newUser == null) {
	  msg = "Error creating new user.";
	  log.error(msg);
	  throw new FtpException(msg);
	}
  
// Create a temporary user in the FTP server.
  user.setEnabled(true);
  user.setName(newUser);
  String newPassword = VMRCServerUtils.generateRandomChain(8);
  user.setPassword(newPassword);
  
 
  if (type == FTPSession.TYPE_UPLOAD){	  
	filePath = RepositoryManager.getRepositoryLocationToStoreFile(vmiName, vmiFileName);
	log.debug("Creating the appropriate dirs to host file: " + vmiFileName);
	new File(filePath).getParentFile().mkdirs();
	user.setHomeDirectory(new File(filePath).getParent());
	List<Authority> auths = new ArrayList<Authority>();
	Authority auth = new WritePermission();
	auths.add(auth);
	user.setAuthorities(auths);
  } else{ //DOWNLOAD
	  String[] files = VMRCServerUtils.listDirectory(RepositoryManager.getRepositoryLocationForVMI(vmiName)); 
	  if (files == null){				  
		  msg = "No file in the repository found for VMI " + vmiName;
		  log.error(msg);
		  throw new FtpException(msg);		  
	  }
	  log.debug("Found " + files.length + " related to " + vmiName + " in the repository. Will pick the first one.");
	  filePath = RepositoryManager.getRepositoryLocationToStoreFile(vmiName,files[0]); 
	  log.debug("Obtained file " + filePath);
  }
  				 
    try {
      // Store the user into users.properties file
      userManager.save(user);
	} catch (FtpException e) {
		log.error("Problems while saving FTP user: " + user);
	   deleteNewUser(newUser);			   
    }
  
	tp.setUser(newUser);
    tp.setPass(newPassword);
    tp.setPath(filePath);
    tp.setHost(this.host);
    tp.setPort(DEFAULT_FTP_PORT);
  return tp;
 }
 
开发者ID:grycap,项目名称:vmrc,代码行数:63,代码来源:SpringFTPServer.java


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