Package org.apache.ftpserver.usermanager.impl

Examples of org.apache.ftpserver.usermanager.impl.BaseUser


    /**
     * 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;
    }
View Full Code Here


           
            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();
View Full Code Here

    private DirectoryLister directoryLister;

    private FileSystemView fileSystemView;

    protected void setUp() throws Exception {
        BaseUser baseUser = new BaseUser();
        baseUser.setHomeDirectory(ROOT_DIR.getAbsolutePath());
        fileSystemView = new NativeFileSystemView(baseUser) {
        };
        directoryLister = new DirectoryLister();

        assertTrue(ROOT_DIR.mkdirs());
View Full Code Here

        // 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);
        }
    }
View Full Code Here

        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File("myusers.properties"));
        userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
        UserManager um = userManagerFactory.createUserManager();
       
        BaseUser user = new BaseUser();
        user.setName("myNewUser");
        user.setPassword("secret");
        user.setHomeDirectory("ftproot");
       
        um.save(user);
    }
View Full Code Here

        // 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);
        }
    }
View Full Code Here

        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>();
        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);
View Full Code Here

        // 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);
        }
    }
View Full Code Here

           
            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();
View Full Code Here

        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File("myusers.properties"));
        userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
        UserManager um = userManagerFactory.createUserManager();
       
        BaseUser user = new BaseUser();
        user.setName("myNewUser");
        user.setPassword("secret");
        user.setHomeDirectory("ftproot");
       
        um.save(user);
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.usermanager.impl.BaseUser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.