Search in sources :

Example 1 with ConcurrentLoginPermission

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

Example 2 with ConcurrentLoginPermission

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;
}
Also used : FtpUser(ddf.catalog.ftp.user.FtpUser) Authority(org.apache.ftpserver.ftplet.Authority) ConcurrentLoginPermission(org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission) ArrayList(java.util.ArrayList) TransferRatePermission(org.apache.ftpserver.usermanager.impl.TransferRatePermission) WritePermission(org.apache.ftpserver.usermanager.impl.WritePermission)

Example 3 with ConcurrentLoginPermission

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;
}
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)

Aggregations

ArrayList (java.util.ArrayList)3 Authority (org.apache.ftpserver.ftplet.Authority)3 ConcurrentLoginPermission (org.apache.ftpserver.usermanager.impl.ConcurrentLoginPermission)3 WritePermission (org.apache.ftpserver.usermanager.impl.WritePermission)3 TransferRatePermission (org.apache.ftpserver.usermanager.impl.TransferRatePermission)2 FtpUser (ddf.catalog.ftp.user.FtpUser)1 ConnectionConfigFactory (org.apache.ftpserver.ConnectionConfigFactory)1 FtpServerFactory (org.apache.ftpserver.FtpServerFactory)1 FtpException (org.apache.ftpserver.ftplet.FtpException)1 ListenerFactory (org.apache.ftpserver.listener.ListenerFactory)1 BaseUser (org.apache.ftpserver.usermanager.impl.BaseUser)1