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


Java UserManager.save方法代码示例

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


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

示例1: start

import org.apache.ftpserver.ftplet.UserManager; //导入方法依赖的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: setUp

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

示例3: setUser

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

示例4: startServer

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

示例5: registerFtpUser

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

示例6: SetupPassword

import org.apache.ftpserver.ftplet.UserManager; //导入方法依赖的package包/类
private static UserManager SetupPassword(final String pass, final int fieldCount) throws FtpException {
    logger.info("Creating FTP Users with password '{}'..", pass);
    final PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    final UserManager um = userManagerFactory.createUserManager();
    for (int i = 1; i != fieldCount + 1; i++) {
        logger.info("FTP User field{} created!", i);
        um.save(MakeUser("field" + i, pass));
    }
    return um;
}
 
开发者ID:VirginiaFIRST,项目名称:FTC-FieldMgmt,代码行数:11,代码来源:Main.java

示例7: createServer

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

示例8: main

import org.apache.ftpserver.ftplet.UserManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
    userManagerFactory.setFile(new File("myusers.properties"));
    userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
    UserManager um = userManagerFactory.createUserManager();

    UserFactory userFact = new UserFactory();
    userFact.setName("myNewUser");
    userFact.setPassword("secret");
    userFact.setHomeDirectory("ftproot");
    User user = userFact.createUser();
    um.save(user);
}
 
开发者ID:saaconsltd,项目名称:mina-ftpserver,代码行数:14,代码来源:ManagingUsers.java

示例9: createDefaultUsers

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

示例10: setUp

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

示例11: startFtpServer

import org.apache.ftpserver.ftplet.UserManager; //导入方法依赖的package包/类
@Before
public void startFtpServer() throws Exception {
    recursiveDelete(resolvePath(FTP_ROOT_DIR).toFile());

    File usersFile = USERS_FILE.toFile();
    usersFile.createNewFile();

    NativeFileSystemFactory fsf = new NativeFileSystemFactory();
    fsf.setCreateHome(true);

    PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory();
    pumf.setAdminName("admin");
    pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor());
    pumf.setFile(usersFile);

    UserManager userMgr = pumf.createUserManager();

    BaseUser user = new BaseUser();
    user.setName("admin");
    user.setPassword("admin");
    user.setHomeDirectory(FTP_ROOT_DIR.toString());

    List<Authority> authorities = new ArrayList<>();
    WritePermission writePermission = new WritePermission();
    writePermission.authorize(new WriteRequest());
    authorities.add(writePermission);
    user.setAuthorities(authorities);
    userMgr.save(user);

    ListenerFactory factory1 = new ListenerFactory();
    factory1.setPort(PORT);

    FtpServerFactory serverFactory = new FtpServerFactory();
    serverFactory.setUserManager(userMgr);
    serverFactory.setFileSystem(fsf);
    serverFactory.setConnectionConfig(new ConnectionConfigFactory().createConnectionConfig());
    serverFactory.addListener("default", factory1.createListener());

    FtpServerFactory factory = serverFactory;
    ftpServer = factory.createServer();
    ftpServer.start();
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:43,代码来源:FtpIntegrationTest.java

示例12: main

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