Package org.apache.ftpserver.interfaces

Examples of org.apache.ftpserver.interfaces.DataConnectionConfiguration


                    "EPRT", null));
            return;
        }

        // is port enabled
        DataConnectionConfiguration dataCfg = session.getListener()
                .getDataConnectionConfiguration();
        if (!dataCfg.isActiveEnabled()) {
            session.write(FtpReplyUtil.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(FtpReplyUtil.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(FtpReplyUtil
                            .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(FtpReplyUtil.translate(session, request,
View Full Code Here


                    "PORT", null));
            return;
        }

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

        InetSocketAddress address;
        try {
            address = SocketAddressEncoder.decode(request.getArgument());
        } catch (IllegalInetAddressException e) {
            session.write(FtpReplyUtil.translate(session, request, context,
                    510, "PORT", null));
            return;
        } catch (IllegalPortException e) {
            LOG.debug("Invalid data port: " + request.getArgument(), e);
            session
                    .write(FtpReplyUtil
                            .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(FtpReplyUtil
                            .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(FtpReplyUtil.translate(session, request,
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.interfaces.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.