use of org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission in project structr by structr.
the class StructrFtpUser method getAuthorities.
@Override
public List<Authority> getAuthorities() {
List<Authority> auths = new ArrayList<>();
auths.add(new ConcurrentLoginPermission(10, 10));
auths.add(new WritePermission());
return auths;
}
use of org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission in project ddf by codice.
the class UserManagerImpl method createUser.
/**
* @param userName name of the user being authenticated
* @param subject {@link Subject} of the user
* @return {@link FtpUser}
*/
protected FtpUser createUser(String userName, Subject subject) {
FtpUser user = new FtpUser();
user.setName(userName);
user.setEnabled(true);
user.setHomeDirectory(uploadDirectory);
List<Authority> authorities = new ArrayList<>();
authorities.add(new WritePermission());
authorities.add(new ConcurrentLoginPermission(0, 0));
authorities.add(new TransferRatePermission(0, 0));
user.setAuthorities(authorities);
user.setMaxIdleTime(MAX_IDLE_TIME_SECONDS);
user.setSubject(subject);
setAdmin(user);
save(user);
return user;
}
use of org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission in project AnExplorer by 1hakr.
the class ConnectionsService method launchServer.
@Override
public boolean launchServer() {
ListenerFactory listenerFactory = new ListenerFactory();
listenerFactory.setPort(ConnectionUtils.getAvailablePortForFTP());
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.addListener("default", listenerFactory.createListener());
ConnectionConfigFactory connectionConfigFactory = new ConnectionConfigFactory();
connectionConfigFactory.setAnonymousLoginEnabled(getNetworkConnection().isAnonymousLogin());
connectionConfigFactory.setMaxLoginFailures(5);
connectionConfigFactory.setLoginFailureDelay(2000);
serverFactory.setConnectionConfig(connectionConfigFactory.createConnectionConfig());
BaseUser user = new BaseUser();
user.setName(getNetworkConnection().getUserName());
user.setPassword(getNetworkConnection().getPassword());
user.setHomeDirectory(getNetworkConnection().getPath());
List<Authority> list = new ArrayList<>();
list.add(new WritePermission());
list.add(new TransferRatePermission(0, 0));
list.add(new ConcurrentLoginPermission(10, 10));
user.setAuthorities(list);
try {
serverFactory.getUserManager().save(user);
} catch (FtpException e) {
CrashReportingManager.logException(e);
}
// do start server
try {
ftpServer = serverFactory.createServer();
ftpServer.start();
return true;
} catch (Exception e) {
ftpServer = null;
handleServerStartError(e);
}
return false;
}
Aggregations