亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ftpconnection.java

?? 一個利用Java語言實現的ftp程序
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE file.
 */
package server.ftp;

import io.IoUtils;
import io.StreamConnector;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.io.Writer;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;

/**
 * This class handles each ftp connection. Here all the ftp command
 * methods take two arguments - a ftp request and a writer object. 
 * This is the main backbone of the ftp server.
 * <br>
 * The ftp command method signature is: 
 * <code>public void doXYZ(FtpRequest request, FtpWriter out) throws IOException</code>.
 * <br>
 * Here <code>XYZ</code> is the capitalized ftp command. 
 *
 * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
 */
public
class FtpConnection extends BaseFtpConnection {
        
    // as SimpleDateFormat is not thread-safe we have to use ThreadLocal
    private final static ThreadLocal DATE_FMT = new ThreadLocal() {
        protected Object initialValue() {
            return new SimpleDateFormat("yyyyMMddHHmmss.SSS"); 
        }
    };
    
    // command state specific temporary variables
    private boolean mbReset   = false;
    private long    mlSkipLen = 0;     
    
    private boolean mbRenFr   = false;
    private String  mstRenFr  = null;
    
    private boolean mbUser    = false;
    private boolean mbPass    = false;
    
    /**
     * Set configuration file and the control socket. 
     */
    public FtpConnection(FtpConfig cfg, Socket soc) {
        super(cfg, soc);
    }
     
    /**
     * Check the user permission to execute this command.
     */
    protected boolean hasPermission(FtpRequest request) {
        String cmd = request.getCommand();
        return mUser.hasLoggedIn() || 
                cmd.equals("USER") || 
                cmd.equals("PASS") ||
                cmd.equals("HELP") ||
                cmd.equals("SYST");
    }
     
    /**
     * Reset temporary state variables.
     */
    private void resetState() {
        mbRenFr = false;
        mstRenFr = null;
            
        mbReset = false;
        mlSkipLen = 0;
            
        mbUser = false;
        mbPass = false;
    }
 
     ////////////////////////////////////////////////////////////
     /////////////////   all the FTP handlers   /////////////////
     ////////////////////////////////////////////////////////////
     /**
      * <code>ABOR &lt;CRLF&gt;</code><br>
      *
      * This command tells the server to abort the previous FTP
      * service command and any associated transfer of data.
      * No action is to be taken if the previous command
      * has been completed (including data transfer).  The control
      * connection is not to be closed by the server, but the data
      * connection must be closed.  
      * Current implementation does not do anything. As here data 
      * transfers are not multi-threaded. 
      */
     public void doABOR(FtpRequest request, FtpWriter out) throws IOException {
         
         // reset state variables
         resetState();
         
         // and abort any data connection
         mDataConnection.closeDataSocket();
         out.write(mFtpStatus.getResponse(226, request, mUser, null));
     }
     
     
     /**
      * <code>APPE &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
      *
      * This command causes the server-DTP to accept the data
      * transferred via the data connection and to store the data in
      * a file at the server site.  If the file specified in the
      * pathname exists at the server site, then the data shall be
      * appended to that file; otherwise the file specified in the
      * pathname shall be created at the server site.
      */
     public void doAPPE(FtpRequest request, FtpWriter out) throws IOException {
         
         InputStream is = null;
         OutputStream os = null;
         String[] args = null;
         
         try {           
         
             // reset state variables
             resetState();
             
             // argument check
             if(!request.hasArgument()) {
                out.write(mFtpStatus.getResponse(501, request, mUser, null));
                return;  
             }
             
             // get filenames
             String fileName = request.getArgument();
             fileName = mUser.getVirtualDirectory().getAbsoluteName(fileName);
             String physicalName = mUser.getVirtualDirectory().getPhysicalName(fileName);
             File requestedFile = new File(physicalName);
             args = new String[] {fileName};
             
             // check file existance
             if( !(requestedFile.exists() && requestedFile.isFile()) ) {
                 out.write(mFtpStatus.getResponse(550, request, mUser, args));
                 return;
             }
             
             // check permission
             if(!mUser.getVirtualDirectory().hasWritePermission(physicalName, true)) {
                 out.write(mFtpStatus.getResponse(450, request, mUser, args));
                 return;
             }
             
             // now transfer file data
             out.write(mFtpStatus.getResponse(150, request, mUser, args));
             Socket dataSoc = mDataConnection.getDataSocket();
             if (dataSoc == null) {
                  out.write(mFtpStatus.getResponse(550, request, mUser, args));
                  return;
             }
             
             // go to the end of the file
             is = dataSoc.getInputStream();
             RandomAccessFile raf = new RandomAccessFile(requestedFile, "rw");
             raf.seek(raf.length());
             os = mUser.getOutputStream( new FileOutputStream(raf.getFD()) );
             
             // receive data from client
             StreamConnector msc = new StreamConnector(is, os);
             msc.setMaxTransferRate(mUser.getMaxUploadRate());
             msc.setObserver(this);
             msc.connect();
             
             if(msc.hasException()) {
                 out.write(mFtpStatus.getResponse(451, request, mUser, args));
             }
             else {
                 mConfig.getStatistics().setUpload(requestedFile, mUser, msc.getTransferredSize());
             }
             
             out.write(mFtpStatus.getResponse(226, request, mUser, args));
         }
         catch(IOException ex) {
             out.write(mFtpStatus.getResponse(425, request, mUser, args));
         }
         finally {
            IoUtils.close(is);
            IoUtils.close(os);
            mDataConnection.closeDataSocket(); 
         }
     }
     
     
     /**
      * <code>CDUP &lt;CRLF&gt;</code><br>
      *
      * This command is a special case of CWD, and is included to
      * simplify the implementation of programs for transferring
      * directory trees between operating systems having different
      * syntaxes for naming the parent directory.  The reply codes
      * shall be identical to the reply codes of CWD.      
      */
     public void doCDUP(FtpRequest request, FtpWriter out) throws IOException {
         
         // reset state variables
         resetState();
         
         // change directory
         if (mUser.getVirtualDirectory().changeDirectory("..")) {
             String args[] = {mUser.getVirtualDirectory().getCurrentDirectory()};
             out.write(mFtpStatus.getResponse(200, request, mUser, args));
         }
         else {
             out.write(mFtpStatus.getResponse(431, request, mUser, null));
         }
     }
     
     
     /**
      * <code>CWD  &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
      *
      * This command allows the user to work with a different
      * directory for file storage or retrieval without
      * altering his login or accounting information.  Transfer
      * parameters are similarly unchanged.  The argument is a
      * pathname specifying a directory.
      */
     public void doCWD(FtpRequest request, FtpWriter out) throws IOException {
         
         // reset state variables
         resetState();
         
         // get new directory name
         String dirName = "/";
         if (request.hasArgument()) {
             dirName = request.getArgument();
         } 
         
         // change directory
         if (mUser.getVirtualDirectory().changeDirectory(dirName)) {
             String args[] = {mUser.getVirtualDirectory().getCurrentDirectory()};
             out.write(mFtpStatus.getResponse(200, request, mUser, args));
         }
         else {
             out.write(mFtpStatus.getResponse(431, request, mUser, null));
         }
     }
     
     
     /**
      * <code>DELE &lt;SP&gt; &lt;pathname&gt; &lt;CRLF&gt;</code><br>
      *
      * This command causes the file specified in the pathname to be
      * deleted at the server site.
      */
     public void doDELE(FtpRequest request, FtpWriter out) throws IOException {
        
        // reset state variables
        resetState();  
         
        // argument check
        if(!request.hasArgument()) {
           out.write(mFtpStatus.getResponse(501, request, mUser, null));
           return;  
        }    
        
        // get filenames
        String fileName = request.getArgument();
        fileName = mUser.getVirtualDirectory().getAbsoluteName(fileName);
        String physicalName = mUser.getVirtualDirectory().getPhysicalName(fileName);
        File requestedFile = new File(physicalName);
        String[] args = {fileName};
        
        // check permission
        if(!mUser.getVirtualDirectory().hasWritePermission(physicalName, true)) {
            out.write(mFtpStatus.getResponse(450, request, mUser, args));
            return;
        }
        
        // now delete
        if(requestedFile.delete()) {
           out.write(mFtpStatus.getResponse(250, request, mUser, args)); 
           mConfig.getStatistics().setDelete(requestedFile, mUser); 
        }
        else {
           out.write(mFtpStatus.getResponse(450, request, mUser, args));
        }
     }
     
     
     /**
      * <code>HELP [&lt;SP&gt; <string>] &lt;CRLF&gt;</code><br>
      *
      * This command shall cause the server to send helpful
      * information regarding its implementation status over the
      * control connection to the user.  The command may take an
      * argument (e.g., any command name) and return more specific
      * information as a response.
      */
     public void doHELP(FtpRequest request, FtpWriter out) throws IOException {
         resetState();
         
         // print global help
         if(!request.hasArgument()) {
             out.write(mFtpStatus.getResponse(214, null, mUser, null));
             return;
         }
         
         // print command specific help
         String ftpCmd = request.getArgument().toUpperCase();
         String args[] = null;
         FtpRequest tempRequest = new FtpRequest(ftpCmd);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品免费| 91丨九色丨蝌蚪丨老版| 麻豆久久久久久久| 国产一区二区精品久久91| 国产资源在线一区| 成人午夜在线播放| 在线观看免费成人| 日韩视频中午一区| 中文字幕亚洲欧美在线不卡| 一区二区三区中文字幕精品精品| 亚洲成人7777| 国产精品中文字幕日韩精品| 色域天天综合网| 国产精品久久久久一区二区三区| 中文字幕免费在线观看视频一区| 亚洲女与黑人做爰| 免费成人你懂的| 99麻豆久久久国产精品免费| 欧美一区二区三区啪啪| 国产精品理论在线观看| 免费精品视频在线| www.欧美亚洲| 精品电影一区二区三区| 亚洲第一成人在线| 一本久久a久久精品亚洲| 精品欧美一区二区久久| 午夜久久电影网| 91丨porny丨国产入口| 欧美精品一区二区三区蜜桃视频 | 精品国产百合女同互慰| 一区二区视频在线看| 成人免费视频网站在线观看| 日韩三级精品电影久久久| 国产另类ts人妖一区二区| 精品一区二区三区日韩| 亚洲女同ⅹxx女同tv| 欧美aaa在线| 69p69国产精品| 天天操天天干天天综合网| 91久久精品国产91性色tv| 国产精品超碰97尤物18| 成年人网站91| 日韩毛片视频在线看| av一区二区久久| 日韩一区在线看| 99re这里只有精品视频首页| 国产精品久久久久久久久晋中| 成a人片国产精品| 综合色中文字幕| 欧美伊人久久久久久午夜久久久久| 亚洲乱码日产精品bd| 欧美专区日韩专区| 天堂资源在线中文精品| 91精品国产高清一区二区三区| 日本sm残虐另类| 欧美成va人片在线观看| 懂色av一区二区三区蜜臀| 国产精品精品国产色婷婷| 在线中文字幕不卡| 美女视频黄久久| 国产亚洲一二三区| 欧美三电影在线| 狠狠色狠狠色综合日日91app| 自拍偷拍国产精品| 91精品国产aⅴ一区二区| 国产成人综合视频| 一区二区国产盗摄色噜噜| 精品理论电影在线| 在线精品视频小说1| 激情欧美一区二区| 亚洲高清免费在线| 亚洲国产经典视频| 欧美撒尿777hd撒尿| 粉嫩av亚洲一区二区图片| 天堂一区二区在线| 亚洲欧美日本韩国| 国产精品色婷婷久久58| 91精品国产色综合久久不卡电影| 国产福利一区在线观看| 香蕉久久夜色精品国产使用方法| 国产三级三级三级精品8ⅰ区| 欧美精品久久久久久久多人混战| 久久免费精品国产久精品久久久久| 99精品在线观看视频| 国产资源精品在线观看| 日av在线不卡| 最近日韩中文字幕| 欧美电影免费观看高清完整版在线观看 | 欧美网站大全在线观看| 成人动漫av在线| 国产91丝袜在线播放| 国产精品综合网| 精品一区二区在线看| 免费观看一级欧美片| 日本视频中文字幕一区二区三区| 亚洲精品国产第一综合99久久| 国产精品初高中害羞小美女文| 国产精品全国免费观看高清 | 日韩高清国产一区在线| 污片在线观看一区二区| 五月综合激情日本mⅴ| 亚洲高清中文字幕| 日韩精品欧美精品| 国内精品视频666| 国产美女av一区二区三区| 国产成人免费视| www.综合网.com| 欧美婷婷六月丁香综合色| 91精品国产色综合久久| 26uuu欧美| 日韩国产精品久久久| 日本午夜一区二区| 国产精品一区二区久久不卡| 99视频有精品| 欧美一区二区性放荡片| 久久精品日产第一区二区三区高清版| 国产欧美日韩不卡| 亚洲国产精品久久艾草纯爱| 日韩主播视频在线| 国产成人精品午夜视频免费| 在线观看日韩av先锋影音电影院| 91精品国产综合久久久久久| 国产精品污污网站在线观看| 亚洲一本大道在线| 国产成人午夜精品5599| 欧美日韩精品一区视频| 国产欧美视频一区二区三区| 亚洲二区在线观看| 成人精品一区二区三区四区| 欧美精品免费视频| 亚洲精品免费一二三区| 国产真实乱子伦精品视频| 欧美日韩国产一区| 亚洲品质自拍视频| 成人av先锋影音| 精品国精品国产| 日韩中文字幕一区二区三区| 欧美高清性hdvideosex| 国产农村妇女精品| 性做久久久久久| 日韩不卡一二三区| 色综合欧美在线| 色哟哟一区二区三区| 精品免费国产一区二区三区四区| 亚洲成人一区二区在线观看| 国产成人免费视频网站| 欧美日本在线视频| 亚洲一区二区三区爽爽爽爽爽| 高清不卡一区二区在线| 久久久三级国产网站| 精品一区二区精品| 精品国产三级a在线观看| 在线观看不卡视频| 亚洲在线视频免费观看| 在线观看免费一区| 亚洲影院免费观看| 欧美精三区欧美精三区| 日韩av午夜在线观看| 日韩精品最新网址| 精品一区二区三区香蕉蜜桃| 国产午夜精品美女毛片视频| 东方aⅴ免费观看久久av| 18涩涩午夜精品.www| 在线观看一区二区视频| 裸体一区二区三区| 久久久蜜桃精品| 99久久伊人精品| 亚洲v精品v日韩v欧美v专区| 日韩精品在线网站| 成人午夜伦理影院| 亚洲国产美女搞黄色| 欧美电视剧在线观看完整版| 丰满少妇在线播放bd日韩电影| 欧美一级高清片| av午夜精品一区二区三区| 亚洲无人区一区| 精品福利在线导航| 94-欧美-setu| 日本不卡高清视频| 国产蜜臀97一区二区三区| 91黄色免费观看| 国产乱子伦视频一区二区三区| 亚洲精品老司机| 精品乱码亚洲一区二区不卡| 91官网在线免费观看| 国产黑丝在线一区二区三区| 玉足女爽爽91| 国产精品久久久久毛片软件| 欧美老肥妇做.爰bbww视频| 丁香婷婷综合色啪| 久久99国产精品久久99果冻传媒| 日韩一区在线播放| 国产欧美日韩在线视频| 精品理论电影在线观看| 欧美精品日韩一本| 欧美日韩精品欧美日韩精品一| 99视频在线精品| 色综合色综合色综合色综合色综合 | 狠狠色丁香久久婷婷综合_中 | 亚洲欧洲制服丝袜|