Search in sources :

Example 6 with FtpException

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;
}
Also used : BaseUser(org.apache.ftpserver.usermanager.impl.BaseUser) Authority(org.apache.ftpserver.ftplet.Authority) ConcurrentLoginPermission(org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission) FtpServerFactory(org.apache.ftpserver.FtpServerFactory) ArrayList(java.util.ArrayList) TransferRatePermission(org.apache.ftpserver.usermanager.impl.TransferRatePermission) FtpException(org.apache.ftpserver.ftplet.FtpException) ConnectionConfigFactory(org.apache.ftpserver.ConnectionConfigFactory) WritePermission(org.apache.ftpserver.usermanager.impl.WritePermission) ListenerFactory(org.apache.ftpserver.listener.ListenerFactory) FtpException(org.apache.ftpserver.ftplet.FtpException)

Example 7 with FtpException

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);
}
Also used : CollectionResource(io.milton.resource.CollectionResource) Resource(io.milton.resource.Resource) BadRequestException(io.milton.http.exceptions.BadRequestException) FtpException(org.apache.ftpserver.ftplet.FtpException) NotAuthorizedException(io.milton.http.exceptions.NotAuthorizedException)

Aggregations

FtpException (org.apache.ftpserver.ftplet.FtpException)7 BadRequestException (io.milton.http.exceptions.BadRequestException)3 NotAuthorizedException (io.milton.http.exceptions.NotAuthorizedException)3 IOException (java.io.IOException)3 FtpServerFactory (org.apache.ftpserver.FtpServerFactory)3 ListenerFactory (org.apache.ftpserver.listener.ListenerFactory)3 BaseUser (org.apache.ftpserver.usermanager.impl.BaseUser)3 Path (io.milton.common.Path)2 CollectionResource (io.milton.resource.CollectionResource)2 ArrayList (java.util.ArrayList)2 ConnectionConfigFactory (org.apache.ftpserver.ConnectionConfigFactory)2 Authority (org.apache.ftpserver.ftplet.Authority)2 WritePermission (org.apache.ftpserver.usermanager.impl.WritePermission)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 CreateStorageRequest (ddf.catalog.content.operation.CreateStorageRequest)1 Metacard (ddf.catalog.data.Metacard)1 IngestException (ddf.catalog.source.IngestException)1 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)1