use of org.apache.ftpserver.ftplet.FtpException 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;
}
use of org.apache.ftpserver.ftplet.FtpException in project lobcder by skoulouzis.
the class MiltonFtpAdapter method createFileSystemView.
@Override
public FileSystemView createFileSystemView(User user) throws FtpException {
MiltonUser mu = (MiltonUser) user;
Resource root;
try {
root = resourceFactory.getResource(mu.domain, "/");
} catch (NotAuthorizedException ex) {
throw new FtpException(ex);
} catch (BadRequestException ex) {
throw new FtpException(ex);
}
return new MiltonFsView(Path.root, (CollectionResource) root, resourceFactory, (MiltonUser) user);
}
Aggregations