You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/02/02 22:11:01 UTC

svn commit: r905801 - in /james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3: ./ core/

Author: norman
Date: Tue Feb  2 21:10:55 2010
New Revision: 905801

URL: http://svn.apache.org/viewvc?rev=905801&view=rev
Log:
Work on getting the pop3 protocol in shape (PROTOCOLS-2)

Added:
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Exception.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractRetrCmdHandler.java
      - copied, changed from r905779, james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractStatCmdHandler.java
      - copied, changed from r905779, james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StatCmdHandler.java
Removed:
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CoreCmdHandlerLoader.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StatCmdHandler.java
Modified:
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCapability.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/ListCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/NoopCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/POP3CommandDispatcherLineHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/PassCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RsetCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StlsCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UnknownCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UserCmdHandler.java
    james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java

Added: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Exception.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Exception.java?rev=905801&view=auto
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Exception.java (added)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Exception.java Tue Feb  2 21:10:55 2010
@@ -0,0 +1,32 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.protocols.pop3;
+
+@SuppressWarnings("serial")
+public class POP3Exception extends Exception{
+	
+	public POP3Exception(String msg, Throwable t) {
+		super(msg,t);
+	}
+
+	public POP3Exception(String msg) {
+		super(msg);
+	}
+}

Copied: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractRetrCmdHandler.java (from r905779, james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java)
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractRetrCmdHandler.java?p2=james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractRetrCmdHandler.java&p1=james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java&r1=905779&r2=905801&rev=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RetrCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractRetrCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -16,150 +16,146 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
+package org.apache.james.protocols.pop3.core;
 
-
-
-package org.apache.james.pop3server.core;
-
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
-import org.apache.mailet.Mail;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.MimeMessage;
+import org.apache.james.protocols.pop3.POP3Exception;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
 /**
-  * Handles RETR command
-  */
-public class RetrCmdHandler implements CommandHandler<POP3Session> {
+ * Handles RETR command
+ */
+public abstract class AbstractRetrCmdHandler implements CommandHandler<POP3Session> {
 
 	private final static String COMMAND_NAME = "RETR";
 
+	/**
+	 * Handler method called upon receipt of a RETR command. This command
+	 * retrieves a particular mail message from the mailbox.
+	 * 
+	 */
+	public Response onCommand(POP3Session session, Request request) {
+		POP3Response response = null;
+		String parameters = request.getArgument();
+		if (session.getHandlerState() == POP3Session.TRANSACTION) {
+			int num = 0;
+			try {
+				num = Integer.parseInt(parameters.trim());
+			} catch (Exception e) {
+				response = new POP3Response(POP3Response.ERR_RESPONSE,
+						"Usage: RETR [mail number]");
+				return response;
+			}
+			try {
+				InputStream msgIn = getMessageInputstream(session, num);
+				response = new POP3Response(POP3Response.OK_RESPONSE,
+						"Message follows");
+				try {
+
+					// write the full mail to the client
+					writeMessageContentTo(msgIn, response, -1);
+
+				} finally {
+					response.appendLine(".");
+
+				}
+				return response;
+
+			} catch (IOException ioe) {
+				response = new POP3Response(POP3Response.ERR_RESPONSE,
+						"Error while retrieving message.");
+			} catch (POP3Exception me) {
+				response = new POP3Response(POP3Response.ERR_RESPONSE,
+						"Error while retrieving message.");
+			} catch (IndexOutOfBoundsException iob) {
+				StringBuilder responseBuffer = new StringBuilder(64).append(
+						"Message (").append(num).append(") does not exist.");
+				response = new POP3Response(POP3Response.ERR_RESPONSE,
+						responseBuffer.toString());
+			}
+		} else {
+			response = new POP3Response(POP3Response.ERR_RESPONSE);
+		}
+		return response;
+	}
+
+	/**
+	 * Return the InputStream for the given message number. Throw Exception if
+	 * no message was found for the number
+	 * 
+	 * @param session
+	 * @param num
+	 * @return message
+	 * @throws POP3Exception
+	 */
+	protected abstract InputStream getMessageInputstream(POP3Session session, int num)
+			throws POP3Exception;
 
-    /**
-     * Handler method called upon receipt of a RETR command.
-     * This command retrieves a particular mail message from the
-     * mailbox.
-     *
+	/**
+	 * Writes the content of the Mail to the client
+	 * 
+	 * @param mail
+	 *            the Mail to write
+	 * @param lines
+	 *            the number of lines to write to the client. If -1 is given it
+	 *            write every line of the given MimeMessage to the client
+	 * @param session
+	 *            the POP3Session to use
+	 * 
+	 * @throws MessagingException
+	 *             if the MimeMessage is not set for this Mail
+	 * @throws IOException
+	 *             if an error occurs while reading or writing from the stream
 	 */
-    public Response onCommand(POP3Session session, Request request) {
-        POP3Response response = null;
-        String parameters = request.getArgument();
-        if (session.getHandlerState() == POP3Session.TRANSACTION) {
-            int num = 0;
-            try {
-                num = Integer.parseInt(parameters.trim());
-            } catch (Exception e) {
-                response = new POP3Response(POP3Response.ERR_RESPONSE, "Usage: RETR [mail number]");
-                return response;
-            }
-            try {
-                Mail mc = session.getUserMailbox().get(num);
-                Mail dm = (Mail) session.getState().get(POP3Session.DELETED);
-
-                if (mc != dm) {
-                    response = new POP3Response(POP3Response.OK_RESPONSE, "Message follows");
-                    try {
-                    	
-                    	// write the full mail to the client
-                        writeMessageContentTo(mc, response, -1);
-                        
-                    } finally {
-                    	response.appendLine(".");
-                      
-                    }
-                    return response;
-                } else {
-                    
-                    StringBuilder responseBuffer =
-                        new StringBuilder(64)
-                                .append("Message (")
-                                .append(num)
-                                .append(") already deleted.");
-                    response = new POP3Response(POP3Response.ERR_RESPONSE,responseBuffer.toString());
-                }
-            } catch (IOException ioe) {
-                response = new POP3Response(POP3Response.ERR_RESPONSE,"Error while retrieving message.");
-            } catch (MessagingException me) {
-                response = new POP3Response(POP3Response.ERR_RESPONSE,"Error while retrieving message.");
-            } catch (IndexOutOfBoundsException iob) {
-                StringBuilder responseBuffer =
-                    new StringBuilder(64)
-                            .append("Message (")
-                            .append(num)
-                            .append(") does not exist.");
-                response = new POP3Response(POP3Response.ERR_RESPONSE,responseBuffer.toString());
-            }
-        } else {
-            response = new POP3Response(POP3Response.ERR_RESPONSE);
-        }
-        return response;
-    }
-
-
-    /**
-     * Writes the content of the Mail to the client
-     *
-     * @param mail the Mail to write
-     * @param lines the number of lines to write to the client. If -1 is given it write every line of the given MimeMessage to the client
-     * @param session the POP3Session to use
-     *
-     * @throws MessagingException if the MimeMessage is not set for this Mail
-     * @throws IOException if an error occurs while reading or writing from the stream
-     */
-	protected void writeMessageContentTo(Mail mail,
-			POP3Response response, int lines)
-			throws IOException, MessagingException {
+	protected void writeMessageContentTo(InputStream mailIn,
+			POP3Response response, int lines) throws IOException {
 		String line;
 		BufferedReader br;
-		MimeMessage message = mail.getMessage();
-
-		if (message != null) {
-			br = new BufferedReader(new InputStreamReader(message
-					.getRawInputStream()));
-			try {
 
-				while (lines == -1 || lines > 0) {
-					if ((line = br.readLine()) == null) {
-						break;
-					}
-
-					// add extra dot if line starts with dot
-					if (line.startsWith(".")) {
-						line = "." + line;
-					}
-					response.appendLine(line);
+		br = new BufferedReader(new InputStreamReader(mailIn));
+		try {
 
-					lines--;
+			while (lines == -1 || lines > 0) {
+				if ((line = br.readLine()) == null) {
+					break;
+				}
 
+				// add extra dot if line starts with dot
+				if (line.startsWith(".")) {
+					line = "." + line;
 				}
+				response.appendLine(line);
+
+				lines--;
 
-			} finally {
-				br.close();
 			}
-		} else {
-			throw new MessagingException("No message set for this Mail!");
+
+		} finally {
+			br.close();
 		}
+
 	}
-	
+
 	/*
 	 * (non-Javadoc)
+	 * 
 	 * @see org.apache.james.api.protocol.CommonCommandHandler#getImplCommands()
 	 */
-    public Collection<String> getImplCommands() {
-        List<String> commands = new ArrayList<String>();
-        commands.add(COMMAND_NAME);
-        return commands;
-    }
+	public Collection<String> getImplCommands() {
+		List<String> commands = new ArrayList<String>();
+		commands.add(COMMAND_NAME);
+		return commands;
+	}
 
 }

Copied: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractStatCmdHandler.java (from r905779, james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StatCmdHandler.java)
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractStatCmdHandler.java?p2=james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractStatCmdHandler.java&p1=james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StatCmdHandler.java&r1=905779&r2=905801&rev=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StatCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/AbstractStatCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,25 +19,23 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import javax.mail.MessagingException;
-
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
-import org.apache.mailet.Mail;
+import org.apache.james.protocols.pop3.POP3Exception;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
   * Handles STAT command
   */
-public class StatCmdHandler implements CommandHandler<POP3Session> {
+public abstract class AbstractStatCmdHandler implements CommandHandler<POP3Session> {
 	private final static String COMMAND_NAME = "STAT";
 
 	/**
@@ -49,24 +47,18 @@
     public Response onCommand(POP3Session session, Request request) {
         POP3Response response = null;
         if (session.getHandlerState() == POP3Session.TRANSACTION) {
-            long size = 0;
-            int count = 0;
+            
             try {
-                Mail dm = (Mail) session.getState().get(POP3Session.DELETED);
-
-                for (Mail mc: session.getUserMailbox()) {
-                    if (mc != dm) {
-                        size += mc.getMessageSize();
-                        count++;
-                    }
-                }
+            	long size = getInboxSize(session);
+                int count = getMessageCount(session);
+                
                 StringBuilder responseBuffer =
                     new StringBuilder(32)
                             .append(count)
                             .append(" ")
                             .append(size);
                 response = new POP3Response(POP3Response.OK_RESPONSE,responseBuffer.toString());
-            } catch (MessagingException me) {
+            } catch (POP3Exception me) {
                 response = new POP3Response(POP3Response.ERR_RESPONSE);
             }
         } else {
@@ -75,6 +67,22 @@
         return response;
     }
 
+    /**
+     * Return the count of all messages in the INBOX
+     * 
+     * @param session
+     * @return size
+     * @throws POP3Exception
+     */
+    protected abstract int getMessageCount(POP3Session session) throws POP3Exception;
+    
+    /**
+     * Return the size of the INBOX
+     * @param session
+     * @return size
+     * @throws POP3Exception
+     */
+    protected abstract int getInboxSize(POP3Session session) throws POP3Exception;
 
 
     /**

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCapability.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCapability.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCapability.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCapability.java Tue Feb  2 21:10:55 2010
@@ -18,11 +18,11 @@
  ****************************************************************/
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Session;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
  * A handler which support the POP3 Extension Mechanism should implement this interface

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/CapaCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -18,19 +18,19 @@
  ****************************************************************/
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.ExtensibleHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
 import org.apache.james.protocols.api.WiringException;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
  * This handler is used to handle CAPA commands
@@ -43,7 +43,7 @@
 
 
 
-	
+
 	/*
 	 * (non-Javadoc)
 	 * @see org.apache.james.protocols.api.CommandHandler#onCommand(org.apache.james.protocols.api.ProtocolSession, org.apache.james.protocols.api.Request)
@@ -62,9 +62,11 @@
 	}
 	
 
-	/**
-	 * @see org.apache.james.api.protocol.ExtensibleHandler#getMarkerInterfaces()
-	 */
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ExtensibleHandler#getMarkerInterfaces()
+     */
 	@SuppressWarnings("unchecked")
     public List<Class<?>> getMarkerInterfaces() {
         List<Class<?>> mList = new ArrayList();
@@ -72,9 +74,10 @@
         return mList;
     }
 
-    /**
-     * @see org.apache.james.api.protocol.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
-     */
+	/*
+	 * (non-Javadoc)
+	 * @see org.apache.james.protocols.api.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
+	 */
     @SuppressWarnings("unchecked")
     public void wireExtensions(Class interfaceName, List extension)
             throws WiringException {
@@ -83,8 +86,9 @@
         }
     }
 
-    /**
-     * @see org.apache.james.api.protocol.CommonCommandHandler#getImplCommands()
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.CommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();
@@ -93,8 +97,9 @@
     }
 
 
-    /**
-     * @see org.apache.james.pop3server.core.CapaCapability#getImplementedCapabilities(org.apache.james.protocols.pop3.pop3server.POP3Session)
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.pop3.core.CapaCapability#getImplementedCapabilities(org.apache.james.protocols.pop3.POP3Session)
      */
 	public List<String> getImplementedCapabilities(POP3Session session) {
 		 List<String> cList = new ArrayList<String>();

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/ListCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/ListCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/ListCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/ListCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,7 +19,7 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -27,17 +27,17 @@
 
 import javax.mail.MessagingException;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 import org.apache.mailet.Mail;
 
 /**
   * Handles LIST command
   */
-public class ListCmdHandler implements CommandHandler<POP3Session> {
+public abstract class ListCmdHandler implements CommandHandler<POP3Session> {
 
 
     /**
@@ -95,7 +95,7 @@
                 int num = 0;
                 try {
                     num = Integer.parseInt(parameters);
-                    Mail mc = session.getUserMailbox().get(num);
+                    int size =getMessageSize(session, num);
                     if (mc != dm) {
                         StringBuilder responseBuffer =
                             new StringBuilder(64)
@@ -134,6 +134,8 @@
         return response;
     }
 
+    protected abstract int getMessageSize(POP3Session session, int num);
+    
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();
         commands.add("LIST");

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/NoopCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/NoopCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/NoopCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/NoopCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,17 +19,17 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
   * Handles NOOP command
@@ -53,10 +53,10 @@
     }
 
 
-
-	/**
-	 * @see org.apache.james.api.protocol.CommonCommandHandler#getImplCommands()
-	 */
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.CommandHandler#getImplCommands()
+     */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();
         commands.add(COMMAND_NAME);

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/POP3CommandDispatcherLineHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/POP3CommandDispatcherLineHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/POP3CommandDispatcherLineHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/POP3CommandDispatcherLineHandler.java Tue Feb  2 21:10:55 2010
@@ -17,18 +17,17 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.AbstractCommandDispatcher;
 import org.apache.james.protocols.api.CommandHandler;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
- * Dispatch 
- * @author norman
+ * Dispatch POP3 Commands
  *
  */
 public class POP3CommandDispatcherLineHandler extends
@@ -38,22 +37,25 @@
   
 
 
-    /**
-     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getMandatoryCommands()
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.AbstractCommandDispatcher#getMandatoryCommands()
      */
     protected List<String> getMandatoryCommands() {
         return Arrays.asList(mandatoryCommands);
     }
 
-    /**
-     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getUnknownCommandHandler()
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.AbstractCommandDispatcher#getUnknownCommandHandler()
      */
     protected CommandHandler<POP3Session> getUnknownCommandHandler() {
         return unknownHandler;
     }
 
-    /**
-     * @see org.apache.james.api.protocol.AbstractCommandDispatcher#getUnknownCommandHandlerIdentifier()
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.AbstractCommandDispatcher#getUnknownCommandHandlerIdentifier()
      */
     protected String getUnknownCommandHandlerIdentifier() {
         return UnknownCmdHandler.COMMAND_NAME;

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/PassCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/PassCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/PassCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/PassCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,51 +19,24 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import javax.annotation.Resource;
-
-import org.apache.james.api.user.UsersRepository;
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
-import org.apache.james.services.MailRepository;
-import org.apache.james.services.MailServer;
-import org.apache.james.util.POP3BeforeSMTPHelper;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
   * Handles PASS command
   */
-public class PassCmdHandler extends RsetCmdHandler {
+public abstract class PassCmdHandler extends RsetCmdHandler {
 
 	private final static String COMMAND_NAME ="PASS";
-	private UsersRepository users;
-	private MailServer mailServer;
-
 
-    /**
-     * Sets the users repository.
-     * @param users the users to set
-     */
-    @Resource(name="localusersrepository")
-    public final void setUsers(UsersRepository users) {
-        this.users = users;
-    }
-	
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="James")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
     
 	/**
      * Handler method called upon receipt of a PASS command.
@@ -75,7 +48,7 @@
         POP3Response response = null;
         if (session.getHandlerState() == POP3Session.AUTHENTICATION_USERSET && parameters != null) {
             String passArg = parameters;
-            if (users.test(session.getUser(), passArg)) {
+            if (authenticate(session.getUser(), passArg)) {
                 try {
                     MailRepository inbox = mailServer.getUserInbox(session.getUser());
                     if (inbox == null) {
@@ -110,6 +83,7 @@
     }
 
   
+    protected abstract  boolean authenticate(String username, String password);
 
     /**
      * @see org.apache.james.api.protocol.CommonCommandHandler#getImplCommands()

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RsetCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RsetCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RsetCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/RsetCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,7 +19,7 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -28,11 +28,11 @@
 
 import javax.mail.MessagingException;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 import org.apache.mailet.Mail;
 
 

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StlsCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StlsCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StlsCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/StlsCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -17,19 +17,18 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
  * Handler which offer STARTTLS implementation for POP3. STARTTLS is started

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/TopCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -38,7 +38,7 @@
 /**
   * Handles TOP command
   */
-public class TopCmdHandler extends RetrCmdHandler implements CapaCapability {
+public class TopCmdHandler extends AbstractRetrCmdHandler implements CapaCapability {
 	private final static String COMMAND_NAME = "TOP";
 
 

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UnknownCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UnknownCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UnknownCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UnknownCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,17 +19,17 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Session;
+import org.apache.james.protocols.pop3.POP3Response;
 
 
 /**

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UserCmdHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UserCmdHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UserCmdHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/UserCmdHandler.java Tue Feb  2 21:10:55 2010
@@ -19,17 +19,18 @@
 
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
+
 import org.apache.james.protocols.api.CommandHandler;
 import org.apache.james.protocols.api.Request;
 import org.apache.james.protocols.api.Response;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 /**
   * Handles NOOP command

Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java?rev=905801&r1=905800&r2=905801&view=diff
==============================================================================
--- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java (original)
+++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java Tue Feb  2 21:10:55 2010
@@ -18,20 +18,19 @@
  ****************************************************************/
 
 
-package org.apache.james.pop3server.core;
+package org.apache.james.protocols.pop3.core;
 
-import org.apache.james.Constants;
-import org.apache.james.pop3server.POP3Response;
-import org.apache.james.pop3server.POP3Session;
 import org.apache.james.protocols.api.ConnectHandler;
+import org.apache.james.protocols.pop3.POP3Response;
+import org.apache.james.protocols.pop3.POP3Session;
 
 public class WelcomeMessageHandler implements ConnectHandler<POP3Session>{
     /** POP3 Server identification string used in POP3 headers */
-    private static final String softwaretype        = "JAMES POP3 Server "
-                                                        + Constants.SOFTWARE_VERSION;
-
-    /**
-     * @see org.apache.james.pop3server.ConnectHandler#onConnect(org.apache.james.protocols.pop3.pop3server.POP3Session)
+    private static final String softwaretype        = "JAMES POP3 Server";
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.protocols.api.ConnectHandler#onConnect(org.apache.james.protocols.api.ProtocolSession)
      */
     public void onConnect(POP3Session session) {
         StringBuilder responseBuffer = new StringBuilder();



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org