james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject svn commit: r1228118 - /james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/
Date Fri, 06 Jan 2012 11:34:30 GMT
Author: eric
Date: Fri Jan  6 11:34:29 2012
New Revision: 1228118

URL: http://svn.apache.org/viewvc?rev=1228118&view=rev
Log:
Import and Class rename / usage to use the new protocols 1.6.0-RC2-SNAPSHOT (JAMES-1360)

Modified:
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/ExtendedSMTPSession.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesWelcomeMessageHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/POP3BeforeSMTPHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
    james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/AddDefaultAttributesMessageHook.java
Fri Jan  6 11:34:29 2012
@@ -43,8 +43,8 @@ public class AddDefaultAttributesMessage
         if (mail instanceof MailImpl) {
 
             final MailImpl mailImpl = (MailImpl) mail;
-            mailImpl.setRemoteHost(session.getRemoteHost());
-            mailImpl.setRemoteAddr(session.getRemoteIPAddress());
+            mailImpl.setRemoteHost(session.getRemoteAddress().getHostName());
+            mailImpl.setRemoteAddr(session.getRemoteAddress().getAddress().toString());
             if (session.getUser() != null) {
                 mail.setAttribute(SMTP_AUTH_USER_ATTRIBUTE_NAME, session.getUser());
             }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/CoreCmdHandlerLoader.java
Fri Jan  6 11:34:29 2012
@@ -22,31 +22,29 @@ package org.apache.james.smtpserver;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.james.protocols.api.handler.HandlersPackage;
-
+import org.apache.james.protocols.api.handler.CommandDispatcher;
+import org.apache.james.protocols.lib.handler.HandlersPackage;
 import org.apache.james.protocols.smtp.core.ExpnCmdHandler;
 import org.apache.james.protocols.smtp.core.HeloCmdHandler;
 import org.apache.james.protocols.smtp.core.HelpCmdHandler;
-import org.apache.james.protocols.smtp.core.log.HookResultLogger;
-
 import org.apache.james.protocols.smtp.core.NoopCmdHandler;
 import org.apache.james.protocols.smtp.core.PostmasterAbuseRcptHook;
 import org.apache.james.protocols.smtp.core.QuitCmdHandler;
 import org.apache.james.protocols.smtp.core.ReceivedDataLineFilter;
 import org.apache.james.protocols.smtp.core.RsetCmdHandler;
-import org.apache.james.protocols.smtp.core.SMTPCommandDispatcherLineHandler;
 import org.apache.james.protocols.smtp.core.VrfyCmdHandler;
 import org.apache.james.protocols.smtp.core.esmtp.AuthCmdHandler;
 import org.apache.james.protocols.smtp.core.esmtp.EhloCmdHandler;
 import org.apache.james.protocols.smtp.core.esmtp.MailSizeEsmtpExtension;
 import org.apache.james.protocols.smtp.core.esmtp.StartTlsCmdHandler;
+import org.apache.james.protocols.smtp.core.log.HookResultLogger;
 
 /**
  * This class represent the base command handlers which are shipped with james.
  */
 public class CoreCmdHandlerLoader implements HandlersPackage {
 
-    private final String COMMANDDISPATCHER = SMTPCommandDispatcherLineHandler.class.getName();
+    private final String COMMANDDISPATCHER = CommandDispatcher.class.getName();
     private final String AUTHCMDHANDLER = AuthCmdHandler.class.getName();
     private final String DATACMDHANDLER = JamesDataCmdHandler.class.getName();
     private final String EHLOCMDHANDLER = EhloCmdHandler.class.getName();

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
Fri Jan  6 11:34:29 2012
@@ -23,11 +23,13 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
 import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
 
 import org.apache.james.core.MailImpl;
 import org.apache.james.core.MimeMessageCopyOnWriteProxy;
@@ -38,6 +40,8 @@ import org.apache.james.protocols.api.Re
 import org.apache.james.protocols.api.handler.ExtensibleHandler;
 import org.apache.james.protocols.api.handler.LineHandler;
 import org.apache.james.protocols.api.handler.WiringException;
+import org.apache.james.protocols.smtp.MailAddress;
+import org.apache.james.protocols.smtp.MailAddressException;
 import org.apache.james.protocols.smtp.MailEnvelope;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
@@ -49,8 +53,9 @@ import org.apache.james.protocols.smtp.h
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookResultHook;
 import org.apache.james.protocols.smtp.hook.MessageHook;
+import org.apache.james.smtpserver.model.MailetMailAddressAdapter;
+import org.apache.james.smtpserver.model.ProtocolMailAddressAdapter;
 import org.apache.mailet.Mail;
-import org.apache.mailet.MailAddress;
 
 /**
  * Handles the calling of JamesMessageHooks
@@ -67,7 +72,11 @@ public class DataLineJamesMessageHookHan
      * @see
      * org.apache.james.protocols.smtp.core.DataLineFilter#onLine(SMTPSession, byte[], LineHandler)
      */
-    public Response onLine(SMTPSession session, byte[] line, LineHandler<SMTPSession>
next) {
+    public Response onLine(SMTPSession session, ByteBuffer lineByteBuffer, LineHandler<SMTPSession>
next) {
+        
+        byte[] line = new byte[lineByteBuffer.remaining()];
+        lineByteBuffer.get(line, 0, line.length);
+        
         MimeMessageInputStreamSource mmiss = (MimeMessageInputStreamSource) session.getState().get(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE);
 
         try {
@@ -80,7 +89,8 @@ public class DataLineJamesMessageHookHan
                 out.close();
 
                 List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
-                MailImpl mail = new MailImpl(MailImpl.getId(), (MailAddress) session.getState().get(SMTPSession.SENDER),
recipientCollection);
+                MailAddress mailAddress = (MailAddress) session.getState().get(SMTPSession.SENDER);
+                MailImpl mail = new MailImpl(MailImpl.getId(), new MailetMailAddressAdapter(mailAddress),
recipientCollection);
 
                 // store mail in the session so we can be sure it get disposed
                 // later
@@ -118,11 +128,13 @@ public class DataLineJamesMessageHookHan
             }
         } catch (IOException e) {
             LifecycleUtil.dispose(mmiss);
-
             SMTPResponse response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT,
DSNStatus.UNDEFINED_STATUS) + " Error processing message: " + e.getMessage());
-
             session.getLogger().error("Unknown error occurred while processing DATA.", e);
-            
+            return response;
+        } catch (AddressException e) {
+            LifecycleUtil.dispose(mmiss);
+            SMTPResponse response = new SMTPResponse(SMTPRetCode.LOCAL_ERROR, DSNStatus.getStatus(DSNStatus.TRANSIENT,
DSNStatus.UNDEFINED_STATUS) + " Error processing message: " + e.getMessage());
+            session.getLogger().error("Invalid email address while processing DATA.", e);
             return response;
         }
         return null;
@@ -270,15 +282,20 @@ public class DataLineJamesMessageHookHan
          * @see org.apache.james.protocols.smtp.MailEnvelope#getSender()
          */
         public MailAddress getSender() {
-            return mail.getSender();
+            try {
+                return new ProtocolMailAddressAdapter( mail.getSender());
+            } catch (MailAddressException e) {
+                // should not occur here, cause it should have happened before
+                throw new RuntimeException(e);
+            }
         }
 
         /**
          * @see org.apache.james.protocols.smtp.MailEnvelope#getSize()
          */
-        public int getSize() {
+        public long getSize() {
             try {
-                return (int)mail.getMessageSize();
+                return (long) mail.getMessageSize();
             } catch (MessagingException e) {
                 return -1;
             }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/ExtendedSMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/ExtendedSMTPSession.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/ExtendedSMTPSession.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/ExtendedSMTPSession.java
Fri Jan  6 11:34:29 2012
@@ -19,6 +19,7 @@
 package org.apache.james.smtpserver;
 
 import org.apache.james.protocols.api.ProtocolTransport;
+import org.apache.james.protocols.api.logger.ProtocolLoggerAdapter;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.smtpserver.netty.SMTPServer.SMTPHandlerConfigurationDataImpl;
@@ -29,17 +30,16 @@ import org.slf4j.Logger;
  */
 public class ExtendedSMTPSession extends org.apache.james.protocols.smtp.SMTPSessionImpl
{
    
-    private SMTPConfiguration theConfigData;
+    private SMTPConfiguration smtpConfiguration;
 
-
-    public ExtendedSMTPSession(SMTPConfiguration theConfigData, Logger logger, ProtocolTransport
transport) {
-        super(theConfigData, logger, transport);
-        this.theConfigData = theConfigData;
+    public ExtendedSMTPSession(SMTPConfiguration smtpConfiguration, Logger logger, ProtocolTransport
transport) {
+        super(new ProtocolLoggerAdapter(logger), transport, smtpConfiguration);
+        this.smtpConfiguration = smtpConfiguration;
     }
 
 	public boolean verifyIdentity() {
-        if (theConfigData instanceof SMTPHandlerConfigurationDataImpl) {
-            return ((SMTPHandlerConfigurationDataImpl) theConfigData).verifyIdentity();
+        if (smtpConfiguration instanceof SMTPHandlerConfigurationDataImpl) {
+            return ((SMTPHandlerConfigurationDataImpl) smtpConfiguration).verifyIdentity();
         } else {
             return true;
         }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesWelcomeMessageHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesWelcomeMessageHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesWelcomeMessageHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/JamesWelcomeMessageHandler.java
Fri Jan  6 11:34:29 2012
@@ -19,6 +19,7 @@
 
 package org.apache.james.smtpserver;
 
+import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.WelcomeMessageHandler;
 
 /**
@@ -29,11 +30,11 @@ public class JamesWelcomeMessageHandler 
     /**
      * SMTP Server identification string used in SMTP headers
      */
-    private final static String SOFTWARE_TYPE = "JAMES SMTP Server"; // +
-                                                                     // Constants.SOFTWARE_VERSION;
+    private final static String SERVICE_TYPE = "JAMES SMTP Server";
 
     @Override
-    protected String getProductName() {
-        return SOFTWARE_TYPE;
+    protected String getServiceType(SMTPSession session) {
+        return SERVICE_TYPE;
     }
+
 }

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/MailPriorityHandler.java
Fri Jan  6 11:34:29 2012
@@ -27,7 +27,7 @@ import java.util.Map;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
@@ -41,7 +41,7 @@ import org.apache.mailet.MailAddress;
  * if the {@link Mail} has more then one recipient, then the highest priority
  * (which was found) is set
  */
-public class MailPriorityHandler implements JamesMessageHook, LifecycleAwareProtocolHandler
{
+public class MailPriorityHandler implements JamesMessageHook, InitializingLifecycleAwareProtocolHandler
{
 
     private Map<String, Integer> prioMap = new HashMap<String, Integer>();
 

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/POP3BeforeSMTPHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/POP3BeforeSMTPHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/POP3BeforeSMTPHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/POP3BeforeSMTPHandler.java
Fri Jan  6 11:34:29 2012
@@ -70,7 +70,7 @@ public class POP3BeforeSMTPHandler imple
         }
 
         // Check if the ip is allowed to relay
-        if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteIPAddress()))
{
+        if (!session.isRelayingAllowed() && POP3BeforeSMTPHelper.isAuthorized(session.getRemoteAddress().getAddress().toString()))
{
             session.setRelayingAllowed(true);
         }
         return null;

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SendMailHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SendMailHandler.java
Fri Jan  6 11:34:29 2012
@@ -68,7 +68,7 @@ public class SendMailHandler implements 
                 recipientString = theRecipients.toString();
             }
             if (session.getLogger().isInfoEnabled()) {
-                StringBuilder infoBuffer = new StringBuilder(256).append("Successfully spooled
mail ").append(mail.getName()).append(" from ").append(mail.getSender()).append(" on ").append(session.getRemoteIPAddress()).append("
for ").append(recipientString);
+                StringBuilder infoBuffer = new StringBuilder(256).append("Successfully spooled
mail ").append(mail.getName()).append(" from ").append(mail.getSender()).append(" on ").append(session.getRemoteAddress().getAddress().toString()).append("
for ").append(recipientString);
                 session.getLogger().info(infoBuffer.toString());
             }
         } catch (MessagingException me) {

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
Fri Jan  6 11:34:29 2012
@@ -22,13 +22,13 @@ import javax.annotation.Resource;
 
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.api.DomainListException;
+import org.apache.james.protocols.smtp.MailAddress;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
-import org.apache.mailet.MailAddress;
 
 /**
  * Handler which check if the authenticated user is incorrect

Modified: james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java?rev=1228118&r1=1228117&r2=1228118&view=diff
==============================================================================
--- james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java
(original)
+++ james/server/trunk/smtpserver/src/main/java/org/apache/james/smtpserver/SetMimeHeaderHandler.java
Fri Jan  6 11:34:29 2012
@@ -23,7 +23,7 @@ import javax.mail.internet.MimeMessage;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.protocols.api.handler.LifecycleAwareProtocolHandler;
+import org.apache.james.protocols.lib.lifecycle.InitializingLifecycleAwareProtocolHandler;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
@@ -32,7 +32,7 @@ import org.apache.mailet.Mail;
 /**
  * Adds the header to the message
  */
-public class SetMimeHeaderHandler implements JamesMessageHook, LifecycleAwareProtocolHandler
{
+public class SetMimeHeaderHandler implements JamesMessageHook, InitializingLifecycleAwareProtocolHandler
{
 
     /**
      * The header name and value that needs to be added



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


Mime
View raw message