Package org.apache.ftpserver.usermanager.impl

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


    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());
       
        userManager.save(user);

    serverFactory.setUserManager(userManager);
    factory.setPort(0);
View Full Code Here


            serverFactory.addListener("default", factory.createListener());

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

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

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

            user.setAuthorities( authorities );

            user.setHomeDirectory( ftpHomeDir.getAbsolutePath() );


            um.save(user);

            serverFactory.setUserManager( um );
View Full Code Here

            serverFactory.addListener("default", factory.createListener());

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

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

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

            user.setAuthorities( authorities );

            user.setHomeDirectory( ftpHomeDir.getAbsolutePath() );


            um.save(user);

            serverFactory.setUserManager( um );
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());
       
        userManager.save(user);

        serverFactory.setUserManager(userManager);
        factory.setPort(0);
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());

        userManager.save(user);

        serverFactory.setUserManager(userManager);
        factory.setPort(0);
View Full Code Here

         */
        public TestUserManager(String adminName,
                PasswordEncryptor passwordEncryptor) {
            super(adminName, passwordEncryptor);

            testUser = new BaseUser();
            testUser.setAuthorities(Arrays
                    .asList(new Authority[] { new ConcurrentLoginPermission(1,
                            1) }));
            testUser.setEnabled(true);
            testUser.setHomeDirectory(TEST_USER_FTP_ROOT);
            testUser.setMaxIdleTime(10000);
            testUser.setName(TEST_USERNAME);
            testUser.setPassword(TEST_PASSWORD);

            anonUser = new BaseUser(testUser);
            anonUser.setName("anonymous");
        }
View Full Code Here

    BaseUser testUser;

    public TestUserManager() {
      super("admin", new ClearTextPasswordEncryptor());
      testUser = new BaseUser();
      testUser.setName("ftpuser");
      testUser.setPassword("ftpuser");
      testUser.setAuthorities(Arrays.asList(new Authority[] { new ConcurrentLoginPermission(3, 3),
        new WritePermission() }));
      testUser.setEnabled(true);
View Full Code Here

  private class TestUserManager implements UserManager {

    private final BaseUser testUser;

    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");
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

            throw new AuthenticationFailedException(authEx);
        }

        try {
            // gather the user
            BaseUser user = getUserByName(principal);
            user.setPassword(credentials);
            // is the user enabled?
            if (!user.getEnabled()) {
                throw new AuthenticationFailedException();
            }

            // scary message for admins if the username/password has not
            // been changed
            if (DEFAULT_USER.equals(user.getName()) && DEFAULT_PASSWORD.equals(credentials)) {
                LOGGER.log(Level.SEVERE, "The default admin/password combination has not been "
                        + "modified, this makes the embedded FTP server an "
                        + "open file host for everybody to use!!!");
            }

            final File dataRoot = dataDir.findOrCreateDataRoot();

            // enable only admins and non anonymous users
            boolean isGSAdmin = false;
            for (GrantedAuthority authority : gsAuth.getAuthorities()) {
                final String userRole = authority.getAuthority();
                if (ADMIN_ROLE.equals(userRole)) {
                    isGSAdmin = true;
                    break;
                }
            }

            final File homeDirectory;
            if (isGSAdmin) {
                homeDirectory = dataRoot;
            } else {
                /*
                 * This resolves the user's home directory to data/incoming/<user name> but does not
                 * create the directory if it does not already exist. That is left to when the user
                 * is authenticated, check the authenticate() method above.
                 */
                homeDirectory = new File(new File(dataRoot, "incoming"), user.getName());
            }
            String normalizedPath = homeDirectory.getAbsolutePath();
            normalizedPath = FilenameUtils.normalize(normalizedPath);
            user.setHomeDirectory(normalizedPath);
            if (!homeDirectory.exists()) {
                LOGGER.fine("Creating FTP home directory for user " + user.getName() + " at "
                        + normalizedPath);
                homeDirectory.mkdirs();
            }

            return 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.