Coverage Report - org.mockftpserver.stub.command.EpsvCommandHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
EpsvCommandHandler
100%
8/8
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 the original author or authors.
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.mockftpserver.stub.command;
 17  
 
 18  
 import org.mockftpserver.core.command.Command;
 19  
 import org.mockftpserver.core.command.CommandHandler;
 20  
 import org.mockftpserver.core.command.InvocationRecord;
 21  
 import org.mockftpserver.core.command.ReplyCodes;
 22  
 import org.mockftpserver.core.session.Session;
 23  
 
 24  
 import java.io.IOException;
 25  
 import java.net.InetAddress;
 26  
 
 27  
 /**
 28  
  * CommandHandler for the EPSV (Extended Address Passive Mode) command. Request the Session to switch
 29  
  * to passive data connection mode. Return a reply code of 229, along with response text of the form:
 30  
  * "<i>Entering Extended Passive Mode (|||PORT|)</i>", where <i>PORT</i> is the 16-bit TCP port
 31  
  * address of the data connection on the server to which the client must connect.
 32  
  * See RFC2428 for more information.
 33  
  * <p/>
 34  
  * Each invocation record stored by this CommandHandler contains no data elements.
 35  
  *
 36  
  * @author Chris Mair
 37  
  * @version $Revision: 230 $ - $Date: 2009-06-13 07:44:57 -0400 (Sat, 13 Jun 2009) $
 38  
  */
 39  
 public class EpsvCommandHandler extends AbstractStubCommandHandler implements CommandHandler {
 40  
 
 41  
     /**
 42  
      * Constructor. Initialize the replyCode.
 43  
      */
 44  59
     public EpsvCommandHandler() {
 45  59
         setReplyCode(ReplyCodes.EPSV_OK);
 46  59
     }
 47  
 
 48  
     /**
 49  
      * @throws java.io.IOException
 50  
      * @see org.mockftpserver.core.command.CommandHandler#handleCommand(org.mockftpserver.core.command.Command, org.mockftpserver.core.session.Session)
 51  
      */
 52  
     public void handleCommand(Command command, Session session, InvocationRecord invocationRecord)
 53  
             throws IOException {
 54  
 
 55  2
         int port = session.switchToPassiveMode();
 56  2
         InetAddress server = session.getServerHost();
 57  2
         LOG.debug("server=" + server + " port=" + port);
 58  2
         sendReply(session, Integer.toString(port));
 59  2
     }
 60  
 
 61  
 }