Package org.apache.ftpserver

Examples of org.apache.ftpserver.DataConnectionConfiguration


                    "EPRT", null));
            return;
        }

        // is port enabled
        DataConnectionConfiguration dataCfg = session.getListener()
                .getDataConnectionConfiguration();
        if (!dataCfg.isActiveEnabled()) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                    510, "EPRT.disabled", null));
            return;
        }

        // parse argument
        String host = null;
        String port = null;
        try {
            char delim = arg.charAt(0);
            int lastDelimIdx = arg.indexOf(delim, 3);
            host = arg.substring(3, lastDelimIdx);
            port = arg.substring(lastDelimIdx + 1, arg.length() - 1);
        } catch (Exception ex) {
            LOG.debug("Exception parsing host and port: " + arg, ex);
            session.write(LocalizedFtpReply.translate(session, request, context,
                    510, "EPRT", null));
            return;
        }

        // get data server
        InetAddress dataAddr = null;
        try {
            dataAddr = InetAddress.getByName(host);
        } catch (UnknownHostException ex) {
            LOG.debug("Unknown host: " + host, ex);
            session
                    .write(LocalizedFtpReply
                            .translate(
                                    session,
                                    request,
                                    context,
                                    FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                                    "EPRT.host", null));
            return;
        }

        // check IP
        if (dataCfg.isActiveIpCheck()) {
            if (session.getRemoteAddress() instanceof InetSocketAddress) {
                InetAddress clientAddr = ((InetSocketAddress) session
                        .getRemoteAddress()).getAddress();
                if (!dataAddr.equals(clientAddr)) {
                    session.write(LocalizedFtpReply.translate(session, request,
View Full Code Here


* @version $Rev: 726046 $, $Date: 2008-12-12 16:31:03 +0100 (Fri, 12 Dec 2008) $
*/
public class PROT extends AbstractCommand {

    private SslConfiguration getSslConfiguration(final FtpIoSession session) {
        DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
       
        SslConfiguration configuration = dataCfg.getSslConfiguration();

        // fall back if no configuration has been provided on the data connection config
        if(configuration == null) {
            configuration = session.getListener().getSslConfiguration();
        }
View Full Code Here

                    "PORT", null));
            return;
        }

        // is port enabled
        DataConnectionConfiguration dataCfg = session.getListener()
                .getDataConnectionConfiguration();
        if (!dataCfg.isActiveEnabled()) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                    510, "PORT.disabled", null));
            return;
        }

        InetSocketAddress address;
        try {
            address = SocketAddressEncoder.decode(request.getArgument());
        } catch (IllegalInetAddressException e) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                    510, "PORT", null));
            return;
        } catch (IllegalPortException e) {
            LOG.debug("Invalid data port: " + request.getArgument(), e);
            session
                    .write(LocalizedFtpReply
                            .translate(
                                    session,
                                    request,
                                    context,
                                    FtpReply.REPLY_552_REQUESTED_FILE_ACTION_ABORTED_EXCEEDED_STORAGE,
                                    "PORT.invalid", null));
            return;
        } catch (UnknownHostException e) {
            LOG.debug("Unknown host", e);
            session
                    .write(LocalizedFtpReply
                            .translate(
                                    session,
                                    request,
                                    context,
                                    FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
                                    "PORT.host", null));
            return;
        }

        // check IP
        if (dataCfg.isActiveIpCheck()) {
            if (session.getRemoteAddress() instanceof InetSocketAddress) {
                InetAddress clientAddr = ((InetSocketAddress) session
                        .getRemoteAddress()).getAddress();
                if (!address.getAddress().equals(clientAddr)) {
                    session.write(LocalizedFtpReply.translate(session, request,
View Full Code Here

            factoryBuilder.addPropertyValue("sslConfiguration", ssl);
        }

        Element dataConElm = SpringUtil.getChildElement(element,
                FtpServerNamespaceHandler.FTPSERVER_NS, "data-connection");
        DataConnectionConfiguration dc = parseDataConnection(dataConElm, ssl);
        factoryBuilder.addPropertyValue("dataConnectionConfiguration", dc);

        if (StringUtils.hasText(element.getAttribute("idle-timeout"))) {
            factoryBuilder.addPropertyValue("idleTimeout", SpringUtil.parseInt(
                    element, "idle-timeout", 300));
View Full Code Here

            factoryBuilder.addPropertyValue("sslConfiguration", ssl);
        }

        Element dataConElm = SpringUtil.getChildElement(element,
                FtpServerNamespaceHandler.FTPSERVER_NS, "data-connection");
        DataConnectionConfiguration dc = parseDataConnection(dataConElm, ssl);
        factoryBuilder.addPropertyValue("dataConnectionConfiguration", dc);

        if (StringUtils.hasText(element.getAttribute("idle-timeout"))) {
            factoryBuilder.addPropertyValue("idleTimeout", SpringUtil.parseInt(
                    element, "idle-timeout", 300));
View Full Code Here

            }

            FtpServerContext ctx = serverContext;

            if (ctx != null) {
                DataConnectionConfiguration dcc = session.getListener()
                        .getDataConnectionConfiguration();
                if (dcc != null) {
                    dcc.releasePassivePort(port);
                }
            }

            servSoc = null;
        }
View Full Code Here

        }

        // open passive server socket and get parameters
        try {
           
          DataConnectionConfiguration dataCfg = session.getListener()
                    .getDataConnectionConfiguration();
         
          String passiveAddress=dataCfg.getPassiveAddress();
         
         

            if (passiveAddress == null) {
                address = serverControlAddress;
            }else{
              address = resolveAddress(dataCfg.getPassiveAddress());
            }

            if (secure) {
                LOG
                        .debug(
                                "Opening SSL passive data connection on address \"{}\" and port {}",
                                address, passivePort);
                SslConfiguration ssl = dataCfg.getSslConfiguration();
                if (ssl == null) {
                    throw new DataConnectionException(
                            "Data connection SSL required but not configured.");
                }
                servSoc = createServerSocket(ssl, address, passivePort);
                port = servSoc.getLocalPort();
                LOG
                        .debug(
                                "SSL Passive data connection created on address \"{}\" and port {}",
                                address, passivePort);
            } else {
                LOG
                        .debug(
                                "Opening passive data connection on address \"{}\" and port {}",
                                address, passivePort);
                servSoc = new ServerSocket(passivePort, 0, address);
                port = servSoc.getLocalPort();
                LOG
                        .debug(
                                "Passive data connection created on address \"{}\" and port {}",
                                address, passivePort);
            }
            servSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);

            // set different state variables
            passive = true;
            requestTime = System.currentTimeMillis();

View Full Code Here

     */
    private synchronized Socket createDataSocket() throws Exception {

        // get socket depending on the selection
        dataSoc = null;
        DataConnectionConfiguration dataConfig = session.getListener()
                .getDataConnectionConfiguration();
        try {
            if (!passive) {
                int localPort = dataConfig.getActiveLocalPort();
                if (secure) {
                    SslConfiguration ssl = dataConfig.getSslConfiguration();
                    if (ssl == null) {
                        throw new FtpException(
                                "Data connection SSL not configured");
                    }
                    if (localPort == 0) {
                        dataSoc = createSocket(ssl, address, port, null,
                                localPort, false);
                    } else {
                        InetAddress localAddr = resolveAddress(dataConfig
                                .getActiveLocalAddress());
                        dataSoc = createSocket(ssl, address, port, localAddr,
                                localPort, false);
                    }
                } else {
                    if (localPort == 0) {
                        dataSoc = new Socket(address, port);
                    } else {
                        InetAddress localAddr =resolveAddress(dataConfig
                                .getActiveLocalAddress());
                        dataSoc = new Socket(address, port, localAddr,
                                localPort);
                    }
                }
            } else {
                LOG.debug("Opening passive data connection");
                dataSoc = servSoc.accept();
                LOG.debug("Passive data connection opened");
            }
        } catch (Exception ex) {
            closeDataConnection();
            LOG.warn("FtpDataConnection.getDataSocket()", ex);
            throw ex;
        }
        dataSoc.setSoTimeout(dataConfig.getIdleTime()*1000);
        // Make sure we initate the SSL handshake, or we'll
        // get an error if we turn out not to send any data
        // e.g. during the listing of an empty dir
        if (dataSoc instanceof SSLSocket) {
            ((SSLSocket) dataSoc).startHandshake();
View Full Code Here

    private void configureServer() {
        FtpServerFactory serverFactory = new FtpServerFactory();
        ListenerFactory listenerFactory = new ListenerFactory();
        DataConnectionConfigurationFactory dataConnConfigFac = new DataConnectionConfigurationFactory();

        DataConnectionConfiguration connectionConfiguration = dataConnConfigFac
                .createDataConnectionConfiguration();

        LOGGER.info("Configuring GeoServer's FTP Server...");
        String passivePorts = config.getPassivePorts();
        if (passivePorts != null && passivePorts.trim().length() > 0) {
View Full Code Here

    private void configureServer() {
        FtpServerFactory serverFactory = new FtpServerFactory();
        ListenerFactory listenerFactory = new ListenerFactory();
        DataConnectionConfigurationFactory dataConnConfigFac = new DataConnectionConfigurationFactory();

        DataConnectionConfiguration connectionConfiguration = dataConnConfigFac
                .createDataConnectionConfiguration();

        LOGGER.info("Configuring GeoServer's FTP Server...");
        String passivePorts = config.getPassivePorts();
        if (passivePorts != null && passivePorts.trim().length() > 0) {
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.DataConnectionConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.