james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From charl...@apache.org
Subject cvs commit: jakarta-james/proposals/v1.3/java/org/apache/james/smtpserver SMTPHandler.java
Date Fri, 15 Jun 2001 12:48:14 GMT
charlesb    01/06/15 05:48:14

  Modified:    proposals/v1.3/java/org/apache/james/smtpserver
                        SMTPHandler.java
  Added:       proposals/v1.3/java/org/apache/james/services
                        MailServer.java
  Log:
  Rejigged EHLO messages, added isLocalServer method to MailServer interface
  
  Revision  Changes    Path
  1.1                  jakarta-james/proposals/v1.3/java/org/apache/james/services/MailServer.java
  
  Index: MailServer.java
  ===================================================================
  /*
   * 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 org.apache.james.services;
  
  import java.io.InputStream;
  import java.util.Collection;
  import javax.mail.MessagingException;
  import javax.mail.internet.*;
  import org.apache.mailet.Mail;
  import org.apache.mailet.MailAddress;
  import org.apache.avalon.phoenix.Service;
  
  /**
   * The interface for Phoenix blocks to the James MailServer
   *
   * @author  Federico Barbieri <scoobie@pop.systemy.it>
   * @author <a href="mailto:charles@benett1.demon.co.uk">Charles Benett</a>
   *
   * This is $Revision: 1.1 $
   * Committed on $Date: 2001/06/15 12:48:12 $ by: $Author: charlesb $ 
   */
  public interface MailServer 
      extends Service {
  
      /**
       * Reserved user name for the mail delivery agent for multi-user mailboxes
       */
      String MDA = "JamesMDA"; 
  
      /**
       * Reserved user name meaning all users for multi-user mailboxes
       */
      String ALL = "AllMailUsers";
  
      /**
       * Pass a MimeMessage to this MailServer for processing
       *
       * @param sender - the sender of the message
       * @param recipients - a Collection of String objects of recipients
       * @param msg - the MimeMessage of the headers and body content of
       * the outgoing message
       * @throws MessagingException - if the message fails to parse
       */
      void sendMail(MailAddress sender, Collection recipients, MimeMessage msg)
          throws MessagingException;
  
      /**
       * Pass a MimeMessage to this MailServer for processing
       *
       * @param sender - the sender of the message
       * @param recipients - a Collection of String objects of recipients
       * @param msg - an InputStream containing the headers and body content of
       * the outgoing message
       * @throws MessagingException - if the message fails to parse
       */
      void sendMail(MailAddress sender, Collection recipients, InputStream msg)
          throws MessagingException;
  
      /**
       * Pass a Mail to this MailServer for processing
       *
       * @param sender - the sender of the message
       * @param recipients - a Collection of String objects of recipients
       * @param msg - an InputStream containing the headers and body content of
       * the outgoing message
       * @throws MessagingException - if the message fails to parse
       */
      void sendMail(Mail mail)
          throws MessagingException;
  
      /**
       * Retrieve the primary mailbox for userName. For POP3 style stores this
       * is their (sole) mailbox. For IMAP style stores this is the INBOX
       * mailbox.
       *
       * @param sender - the name of the user
       * @returns a reference to an initialised mailbox
       */
      MailRepository getUserInbox(String userName);
  
      String getId();
  
      /**
       * Adds a new user to the mail system with userName. For POP3 style stores
       * this may only involve adding the user to the UsersStore.
       * For IMAP style stores this involves creating malboxes with appropriate
       * ACLs. Additional considerations apply if there has been a previous user
       * with the same name in an IMAP system.
       * mailbox.
       *
       * @param sender - the name of the user
       * @returns a reference to an initialised mailbox
       */
      boolean addUser(String userName, String password);
  
      /**
       * Checks if a server is serviced by mail context
       *
       * @param serverName - name of server.
       * @return true if server is local, i.e. serviced by this mail context
       */
      boolean isLocalServer(String serverName);
  }
  
  
  
  1.4       +25 -13    jakarta-james/proposals/v1.3/java/org/apache/james/smtpserver/SMTPHandler.java
  
  Index: SMTPHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/proposals/v1.3/java/org/apache/james/smtpserver/SMTPHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SMTPHandler.java	2001/06/14 15:55:39	1.3
  +++ SMTPHandler.java	2001/06/15 12:48:13	1.4
  @@ -43,8 +43,8 @@
    * @author Jason Borden <jborden@javasense.com>
    * @author Matthew Pangaro <mattp@lokitech.com>
    *
  - * This is $Revision: 1.3 $
  - * Committed on $Date: 2001/06/14 15:55:39 $ by: $Author: charlesb $ 
  + * This is $Revision: 1.4 $
  + * Committed on $Date: 2001/06/15 12:48:13 $ by: $Author: charlesb $ 
    */
   public class SMTPHandler
       extends BaseConnectionHandler
  @@ -81,7 +81,6 @@
       private TimeScheduler scheduler;
       private UsersRepository users;
       private MailServer mailServer;
  -    private James parentJames;
   
       private String softwaretype = "JAMES SMTP Server "
                                      + Constants.SOFTWARE_VERSION;
  @@ -110,8 +109,6 @@
           throws ComponentException {
           mailServer = (MailServer)componentManager.lookup(
                                    "org.apache.james.services.MailServer");
  -        parentJames = (James)componentManager.lookup(
  -                             "org.apache.james.services.MailServer");
           scheduler = (TimeScheduler)componentManager.lookup(
               "org.apache.avalon.cornerstone.services.scheduler.TimeScheduler");
           UsersStore usersStore = (UsersStore)componentManager.lookup(
  @@ -260,23 +257,38 @@
       private void doHELO(String command,String argument,String argument1) {
           if (state.containsKey(CURRENT_HELO_MODE)) {
               out.println("250 " + state.get(SERVER_NAME)
  -                        + " Duplicate HELO/EHLO");
  +                        + " Duplicate HELO");
           } else if (argument == null) {
               out.println("501 domain address required: " + command);
           } else {
               state.put(CURRENT_HELO_MODE, command);
               state.put(NAME_GIVEN, argument);
  -            out.println(((authRequired) ? "250-AUTH LOGIN PLAIN\r\n" : "")
  -                        + "250 " + state.get(SERVER_NAME) + " Hello "
  +            out.println( "250 " + state.get(SERVER_NAME) + " Hello "
                           + argument + " (" + state.get(REMOTE_NAME)
                           + " [" + state.get(REMOTE_IP) + "])");
           }
       }
       private void doEHLO(String command,String argument,String argument1) {
  -        doHELO(command,argument,argument1);
  -	if (maxmessagesize > 0) {
  -	    //    out.println("250 SIZE " + maxmessagesize);
  +        if (state.containsKey(CURRENT_HELO_MODE)) {
  +            out.println("250 " + state.get(SERVER_NAME)
  +                        + " Duplicate EHLO");
  +        } else if (argument == null) {
  +            out.println("501 domain address required: " + command);
  +        } else {
  +            state.put(CURRENT_HELO_MODE, command);
  +            state.put(NAME_GIVEN, argument);
  +            out.println( "250 " + state.get(SERVER_NAME) + " Hello "
  +                        + argument + " (" + state.get(REMOTE_NAME)
  +                        + " [" + state.get(REMOTE_IP) + "])");
  +	    if (maxmessagesize > 0) {
  +	        //    out.println("250 SIZE " + maxmessagesize);
  +            }
  +	    if (authRequired) {
  +	        out.println("250 AUTH LOGIN PLAIN");
  +            }
           }
  +
  +
       }
   
       private void doAUTH(String command,String argument,String argument1)
  @@ -406,7 +418,7 @@
                       String toDomain
                            = recipient.substring(recipient.indexOf('@') + 1);
                       
  -                    if (!parentJames.isLocalServer(toDomain)) {
  +                    if (!mailServer.isLocalServer(toDomain)) {
                           out.println("530 Authentication Required");
                           getLogger().error(
                               "Authentication is required for mail request");
  @@ -428,7 +440,7 @@
                               + senderAddress);
                           return;
                         }                        
  -                      if (!parentJames.isLocalServer(
  +                      if (!mailServer.isLocalServer(
                                          senderAddress.getHost())) {
                           out.println("503 Incorrect Authentication for Specified Email Address");
                           getLogger().error("User " + authUser
  
  
  

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


Mime
View raw message