noel        2003/07/15 20:58:44

  Modified:    src/java/org/apache/james/pop3server Tag: branch_2_1_fcs
                        POP3Handler.java
  Log:
  Change to use CRLFTerminatedReader.  Follows same pattern that SMTPHandler has been 
using.  Also some minor text changes to make spotting differences with MAIN easier.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.18.4.5  +30 -13    
james-server/src/java/org/apache/james/pop3server/POP3Handler.java
  
  Index: POP3Handler.java
  ===================================================================
  RCS file: 
/home/cvs/james-server/src/java/org/apache/james/pop3server/POP3Handler.java,v
  retrieving revision 1.18.4.4
  retrieving revision 1.18.4.5
  diff -u -r1.18.4.4 -r1.18.4.5
  --- POP3Handler.java  12 Jul 2003 23:44:14 -0000      1.18.4.4
  +++ POP3Handler.java  16 Jul 2003 03:58:44 -0000      1.18.4.5
  @@ -70,6 +70,7 @@
   import org.apache.james.services.MailServer;
   import org.apache.james.services.UsersRepository;
   import org.apache.james.services.UsersStore;
  +import org.apache.james.util.CRLFTerminatedReader;
   import org.apache.james.util.ExtraDotOutputStream;
   import org.apache.james.util.InternetPrintWriter;
   import org.apache.james.util.watchdog.BytesWrittenResetOutputStream;
  @@ -85,8 +86,6 @@
   /**
    * The handler class for POP3 connections.
    *
  - * @author Federico Barbieri <[EMAIL PROTECTED]>
  - * @author Peter M. Goldstein <[EMAIL PROTECTED]>
    */
   public class POP3Handler
       extends AbstractLogEnabled
  @@ -135,7 +134,7 @@
       private MailRepository userInbox;
   
       /**
  -     * The thread executing this handler 
  +     * The thread executing this handler
        */
       private Thread handlerThread;
   
  @@ -177,7 +176,7 @@
        */
       private ArrayList userMailbox = new ArrayList();
   
  -    private ArrayList backupUserMailbox;         // A snapshot list representing 
the set of 
  +    private ArrayList backupUserMailbox;         // A snapshot list representing 
the set of
                                                    // emails in the user's inbox at 
the beginning
                                                    // of the transaction
   
  @@ -260,7 +259,8 @@
               synchronized (this) {
                   handlerThread = Thread.currentThread();
               }
  -            in = new BufferedReader(new InputStreamReader(socket.getInputStream(), 
"ASCII"), 512);
  +            // in = new BufferedReader(new 
InputStreamReader(socket.getInputStream(), "ASCII"), 512);
  +            in = new CRLFTerminatedReader(new 
BufferedInputStream(socket.getInputStream(), 512), "ASCII");
               remoteIP = socket.getInetAddress().getHostAddress ();
               remoteHost = socket.getInetAddress().getHostName ();
           } catch (Exception e) {
  @@ -299,12 +299,12 @@
                           .append(" ")
                           .append(theConfigData.getHelloName())
                           .append(" POP3 server (")
  -                        .append(this.softwaretype)
  +                        .append(POP3Handler.softwaretype)
                           .append(") ready ");
               out.println(responseBuffer.toString());
   
               theWatchdog.start();
  -            while (parseCommand(in.readLine())) {
  +            while (parseCommand(readCommandLine())) {
                   theWatchdog.reset();
               }
               theWatchdog.stop();
  @@ -417,7 +417,7 @@
        * Implements a "stat".  If the handler is currently in
        * a transaction state, this amounts to a rollback of the
        * mailbox contents to the beginning of the transaction.
  -     * This method is also called when first entering the 
  +     * This method is also called when first entering the
        * transaction state to initialize the handler copies of the
        * user inbox.
        *
  @@ -427,7 +427,7 @@
           userMailbox.add(DELETED);
           for (Iterator it = userInbox.list(); it.hasNext(); ) {
               String key = (String) it.next();
  -            MailImpl mc = userInbox.retrieve(key);
  +            Mail mc = userInbox.retrieve(key);
               // Retrieve can return null if the mail is no longer in the store.
               // In this case we simply continue to the next key
               if (mc == null) {
  @@ -439,6 +439,24 @@
       }
   
       /**
  +     * Reads a line of characters off the command line.
  +     *
  +     * @return the trimmed input line
  +     * @throws IOException if an exception is generated reading in the input 
characters
  +     */
  +    final String readCommandLine() throws IOException {
  +        for (;;) try {
  +            String commandLine = in.readLine();
  +            if (commandLine != null) {
  +                commandLine = commandLine.trim();
  +            }
  +            return commandLine;
  +        } catch (CRLFTerminatedReader.TerminationException te) {
  +            writeLoggedFlushedResponse("-ERR Syntax error at character position " + 
te.position() + ". CR and LF must be CRLF paired.  See RFC 1939 #3.");
  +        }
  +    }
  +
  +    /**
        * This method parses POP3 commands read off the wire in handleConnection.
        * Actual processing of the command (possibly including additional back and
        * forth communication with the client) is delegated to one of a number of
  @@ -455,8 +473,7 @@
               return false;
           }
           boolean returnValue = true;
  -        String command = rawCommand.trim();
  -        rawCommand = command;
  +        String command = rawCommand;
           StringTokenizer commandLine = new StringTokenizer(command, " ");
           int arguments = commandLine.countTokens();
           if (arguments == 0) {
  @@ -1064,7 +1081,7 @@
       }
   
       /**
  -     * This method logs at a "DEBUG" level the response string that 
  +     * This method logs at a "DEBUG" level the response string that
        * was sent to the POP3 client.  The method is provided largely
        * as syntactic sugar to neaten up the code base.  It is declared
        * private and final to encourage compiler inlining.
  @@ -1091,7 +1108,7 @@
       }
   
       /**
  -     * Write a response string.  The response is also logged. 
  +     * Write a response string.  The response is also logged.
        * Used for multi-line responses.
        *
        * @param responseString the response string sent to the client
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to