public String[] getAllUserNames() throws FtpException { return new String[] {TEST_USERNAME, anonUser.getName()}; }
public User getUserByName(String username) throws FtpException { if(TEST_USERNAME.equals(username)) { return testUser; } else if(anonUser.getName().equals(username)) { return anonUser; } return null; }
public boolean doesExist(String username) throws FtpException { return (TEST_USERNAME.equals(username) || anonUser.getName().equals(username)) ? true : false; }
public User authenticate(Authentication authentication) throws AuthenticationFailedException { if(UsernamePasswordAuthentication.class.isAssignableFrom(authentication.getClass())) { UsernamePasswordAuthentication upAuth = (UsernamePasswordAuthentication) authentication; if(TEST_USERNAME.equals(upAuth.getUsername()) && TEST_PASSWORD.equals(upAuth.getPassword())) { return testUser; } if(anonUser.getName().equals(upAuth.getUsername())) { return anonUser; } } else if(AnonymousAuthentication.class.isAssignableFrom(authentication.getClass())) { return anonUser; } return null; } }
FtpUserManager(Properties configuration, String adminName, PasswordEncryptor passwordEncryptor) { super(adminName, passwordEncryptor); this.configuration = configuration; // load users BaseUser user = loadUser("", "user", "user"); users.put(user.getName(), user); int i = 2; while ((user = loadUser(String.valueOf(i++), null, null)) != null) { users.put(user.getName(), user); } // configure anonymous user user = new BaseUser(); user.setName("anonymous"); user.setHomeDirectory(configuration.getProperty("ftp.anonymous.home", "")); user.setMaxIdleTime(300); user.setEnabled(Boolean.valueOf(configuration.getProperty("ftp.anonymous.enabled", "false"))); List<Authority> authorities = new ArrayList<>(); final String rights = configuration.getProperty("ftp.anonymous.rights", "pwd|cd|dir|put|get|rename|delete|mkdir|rmdir|append"); parseAuthorities(authorities, rights); authorities.add(new WritePermission()); authorities.add(new ConcurrentLoginPermission(10, 5)); user.setAuthorities(authorities); // add user to application users.put(user.getName(), user); }
private BaseUser loadUser(String suffix, String defaultUser, String defaultPassword) { final String username = configuration.getProperty("ftp.user" + suffix, defaultUser); final String password = configuration.getProperty("ftp.pass" + suffix, defaultPassword); if ((username == null || username.length() == 0) || (password == null || password.length() == 0)) { return null; } BaseUser user = new BaseUser(); user.setEnabled(true); user.setHomeDirectory(configuration.getProperty("ftp.home" + suffix, "")); user.setMaxIdleTime(300); user.setName(username); user.setPassword(password); List<Authority> authorities = new ArrayList<>(); // configure permissions final String rights = configuration.getProperty("ftp.rights" + suffix, "pwd|cd|dir|put|get|rename|delete|mkdir|rmdir|append"); parseAuthorities(authorities, rights); authorities.add(new WritePermission()); authorities.add(new ConcurrentLoginPermission(10, 5)); user.setAuthorities(authorities); LOG.info("FTP User Manager configured for user '" + user.getName() + "'"); LOG.info("FTP rights '" + rights + "'"); return user; }
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 " homeDirectory = new File(new File(dataRoot, "incoming"), user.getName()); user.setHomeDirectory(normalizedPath); if (!homeDirectory.exists()) { LOGGER.fine("Creating FTP home directory for user " + user.getName() + " at " + normalizedPath); homeDirectory.mkdirs();
if(TEST_USERNAME.equals(username)) { return testUser; } else if(anonUser.getName().equals(username)) { return anonUser; return new String[] {TEST_USERNAME, anonUser.getName()}; return (TEST_USERNAME.equals(username) || anonUser.getName().equals(username)) ? true : false; if(anonUser.getName().equals(upAuth.getUsername())) { return anonUser;
if(TEST_USERNAME.equals(username)) { return testUser; } else if(anonUser.getName().equals(username)) { return anonUser; return new String[] {TEST_USERNAME, anonUser.getName()}; return (TEST_USERNAME.equals(username) || anonUser.getName().equals(username)) ? true : false; if(anonUser.getName().equals(upAuth.getUsername())) { return anonUser;