Examples of ServerFtpStatistics


Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

        } catch(Exception e) {
            // shallow the exception, we're closing down the session anyways
            LOG.warn("Ftplet threw an exception on disconnect", e);
        }
       
        ServerFtpStatistics stats = ((ServerFtpStatistics)context.getFtpStatistics());
     
      if(stats != null) {
        stats.setLogout(session);
      }
    }
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

            // write log message
            String userName = session.getUser().getName();
            LOG.info("Directory create : " + userName + " - " + fileName);
           
            // notify statistics object
            ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
            ftpStat.setMkdir(session, file);
           
            // call Ftplet.onMkdirEnd() method
            try{
                ftpletRet = ftpletContainer.onMkdirEnd(session.getFtpletSession(), request);
            } catch(Exception e) {
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

                // log message
                String userName = session.getUser().getName();
                LOG.info("File download : " + userName + " - " + fileName);
               
                // notify the statistics component
                ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
                if(ftpStat != null)  {
                    ftpStat.setDownload(session, file, transSz);
                }
            }
            catch(SocketException ex) {
                LOG.debug("Socket exception during data transfer", ex);
                failure = true;
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

    public void execute(final FtpIoSession session,
            final FtpServerContext context,
            final FtpRequest request) throws IOException, FtpException {
   
        boolean success = false;
        ServerFtpStatistics stat = (ServerFtpStatistics)context.getFtpStatistics();
        try {
           
            // reset state variables
            session.resetState();
           
            // argument check
            String userName = request.getArgument();
            if(userName == null) {
                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "USER", null));
                return
            }
           
            // Add to the MDC logging
            MdcInjectionFilter.setProperty(session, "userName", userName);
           
            // already logged-in
            BaseUser user = (BaseUser)session.getUser();
            if(session.isLoggedIn()) {
                if( userName.equals(user.getName()) ) {
                    session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_230_USER_LOGGED_IN, "USER", null));
                    success = true;
                }
                else {
                    session.write(FtpReplyUtil.translate(session, request, context, 530, "USER.invalid", null));
                }
                return;
            }
           
            // anonymous login is not enabled
            boolean anonymous = userName.equals("anonymous");
            if( anonymous && (!context.getConnectionConfig().isAnonymousLoginEnabled()) ) {
                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_530_NOT_LOGGED_IN, "USER.anonymous", null));
                return;
            }
           
            // anonymous login limit check
            int currAnonLogin = stat.getCurrentAnonymousLoginNumber();
            int maxAnonLogin = context.getConnectionConfig().getMaxAnonymousLogins();
            if( anonymous && (currAnonLogin >= maxAnonLogin) ) {
                session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "USER.anonymous", null));
                return;
            }
           
            // login limit check
            int currLogin = stat.getCurrentLoginNumber();
            int maxLogin = context.getConnectionConfig().getMaxLogins();
            if(maxLogin != 0 && currLogin >= maxLogin) {
              session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "USER.login", null));
                return;
            }
           
            User configUser = context.getUserManager().getUserByName(userName);
            if(configUser != null){
                //user login limit check
               
              InetAddress address = null;
              if(session.getRemoteAddress() instanceof InetSocketAddress) {
                address = ((InetSocketAddress)session.getRemoteAddress()).getAddress();
              }
             
                ConcurrentLoginRequest loginRequest = new  ConcurrentLoginRequest(
                        stat.getCurrentUserLoginNumber(configUser) + 1,
                        stat.getCurrentUserLoginNumber(configUser, address) + 1);
               
                if(configUser.authorize(loginRequest) == null) {
                  session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION, "USER.login", null));
                    return;
                }
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

            String userName = session.getUser().getName();
           
            LOG.info("File delete : " + userName + " - " + fileName);
           
            // notify statistics object
            ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
            ftpStat.setDelete(session, file);
           
            // call Ftplet.onDeleteEnd() method
            try{
                ftpletRet = ftpletContainer.onDeleteEnd(session.getFtpletSession(), request);
            } catch(Exception e) {
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

                // log message
                String userName = session.getUser().getName();
                LOG.info("File upload : " + userName + " - " + fileName);
               
                // notify the statistics component
                ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
                if(ftpStat != null) {
                    ftpStat.setUpload(session, file, transSz);
                }
            }
            catch(SocketException ex) {
                LOG.debug("Socket exception during data transfer", ex);
                failure = true;
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

    public void execute(final FtpIoSession session,
            final FtpServerContext context, final FtpRequest request)
            throws IOException, FtpException {

        boolean success = false;
        ServerFtpStatistics stat = (ServerFtpStatistics) context
                .getFtpStatistics();
        try {

            // reset state variables
            session.resetState();

            // argument check
            String userName = request.getArgument();
            if (userName == null) {
                session
                        .write(FtpReplyUtil
                                .translate(
                                        session,
                                        request,
                                        context,
                                        FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
                                        "USER", null));
                return;
            }

            // Add to the MDC logging
            MdcInjectionFilter.setProperty(session, "userName", userName);

            // already logged-in
            User user = session.getUser();
            if (session.isLoggedIn()) {
                if (userName.equals(user.getName())) {
                    session.write(FtpReplyUtil.translate(session, request,
                            context, FtpReply.REPLY_230_USER_LOGGED_IN, "USER",
                            null));
                    success = true;
                } else {
                    session.write(FtpReplyUtil.translate(session, request,
                            context, 530, "USER.invalid", null));
                }
                return;
            }

            // anonymous login is not enabled
            boolean anonymous = userName.equals("anonymous");
            if (anonymous
                    && (!context.getConnectionConfig()
                            .isAnonymousLoginEnabled())) {
                session.write(FtpReplyUtil.translate(session, request, context,
                        FtpReply.REPLY_530_NOT_LOGGED_IN, "USER.anonymous",
                        null));
                return;
            }

            // anonymous login limit check
            int currAnonLogin = stat.getCurrentAnonymousLoginNumber();
            int maxAnonLogin = context.getConnectionConfig()
                    .getMaxAnonymousLogins();
            if (anonymous && (currAnonLogin >= maxAnonLogin)) {
                session
                        .write(FtpReplyUtil
                                .translate(
                                        session,
                                        request,
                                        context,
                                        FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,
                                        "USER.anonymous", null));
                return;
            }

            // login limit check
            int currLogin = stat.getCurrentLoginNumber();
            int maxLogin = context.getConnectionConfig().getMaxLogins();
            if (maxLogin != 0 && currLogin >= maxLogin) {
                session
                        .write(FtpReplyUtil
                                .translate(
                                        session,
                                        request,
                                        context,
                                        FtpReply.REPLY_421_SERVICE_NOT_AVAILABLE_CLOSING_CONTROL_CONNECTION,
                                        "USER.login", null));
                return;
            }

            User configUser = context.getUserManager().getUserByName(userName);
            if (configUser != null) {
                // user login limit check

                InetAddress address = null;
                if (session.getRemoteAddress() instanceof InetSocketAddress) {
                    address = ((InetSocketAddress) session.getRemoteAddress())
                            .getAddress();
                }

                ConcurrentLoginRequest loginRequest = new ConcurrentLoginRequest(
                        stat.getCurrentUserLoginNumber(configUser) + 1,
                        stat.getCurrentUserLoginNumber(configUser, address) + 1);

                if (configUser.authorize(loginRequest) == null) {
                    session
                            .write(FtpReplyUtil
                                    .translate(
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

            String userName = session.getUser().getName();

            LOG.info("File delete : " + userName + " - " + fileName);

            // notify statistics object
            ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
                    .getFtpStatistics();
            ftpStat.setDelete(session, file);
        } else {
            session.write(FtpReplyUtil.translate(session, request, context,
                    FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE",
                    fileName));
        }
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

        } catch (Exception e) {
            // shallow the exception, we're closing down the session anyways
            LOG.warn("Ftplet threw an exception on disconnect", e);
        }

        ServerFtpStatistics stats = ((ServerFtpStatistics) context
                .getFtpStatistics());

        if (stats != null) {
            stats.setLogout(session);
        }
    }
View Full Code Here

Examples of org.apache.ftpserver.interfaces.ServerFtpStatistics

                String userName = session.getUser().getName();

                LOG.info("File upload : " + userName + " - " + fileName);

                // notify the statistics component
                ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
                        .getFtpStatistics();
                ftpStat.setUpload(session, file, transSz);
            } catch (SocketException e) {
                LOG.debug("SocketException during file upload", e);
                failure = true;
                session.write(FtpReplyUtil.translate(session, request, context,
                        FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.