Java Code Examples for org.apache.ftpserver.usermanager.impl.BaseUser#setEnabled()
The following examples show how to use
org.apache.ftpserver.usermanager.impl.BaseUser#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StorageServerTools.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
private static UserManager concreteUserManager(List<Account> list) throws Exception { List<BaseUser> users = new ArrayList<>(); for (Account o : list) { BaseUser user = new BaseUser(); user.setEnabled(true); user.setName(o.getUsername()); String password = o.getPassword(); if (StringUtils.isEmpty(password)) { password = Config.token().getPassword(); } user.setPassword(password); File file = new File(Config.base(), "local/repository/storage/" + o.getUsername()); FileUtils.forceMkdir(file); user.setHomeDirectory(file.getAbsolutePath()); user.setMaxIdleTime(0); List<Authority> authorities = new ArrayList<Authority>(); authorities.add(new WritePermission()); authorities.add(new ConcurrentLoginPermission(0, 0)); authorities.add(new TransferRatePermission(0, 0)); user.setAuthorities(authorities); users.add(user); } StorageUserManager userManager = new StorageUserManager(users); return userManager; }
Example 2
Source File: FtpUserManager.java From google-drive-ftp-adapter with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 3
Source File: FTPServer.java From portable-ftp-server with GNU General Public License v3.0 | 5 votes |
/** * Sets the user. * * @param login the login * @param password the password * @param home the home */ public void setUser(String login,char[] password,String home){ BaseUser user = new BaseUser(); user.setName(login); if(password !=null && password.length>0){ user.setPassword(new String(password)); } user.setHomeDirectory(home); user.setEnabled(true); userManager.setUser(user); }
Example 4
Source File: InMemoryUserManagerTest.java From portable-ftp-server with GNU General Public License v3.0 | 5 votes |
/** * Instantiates a new in memory user manager test. */ public InMemoryUserManagerTest(){ imum = new InMemoryUserManager(); BaseUser user = new BaseUser(); user.setName(USER); user.setPassword(USER); user.setEnabled(true); imum.setUser(user); }
Example 5
Source File: InMemoryUserManagerTest.java From portable-ftp-server with GNU General Public License v3.0 | 5 votes |
/** * Save ignored T est. * * @throws FtpException the ftp exception */ @Test public void saveIgnoredTEst() throws FtpException{ BaseUser user = new BaseUser(); user.setName("admin2"); user.setPassword(USER); user.setEnabled(true); imum.save(user); User u1 = imum.getUserByName("admin2"); assertNotNull(u1); assertEquals(USER,u1.getName()); }
Example 6
Source File: DHuSFtpUserManager.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@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; }
Example 7
Source File: FtpsServer.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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(); }