Hello,
I am Anagha Mudigonda, Graduate Student Polytechnic
University New York.
I shall be implementing In-Protocol framework and Fast
FAIL as a part of Google SOC and 
subsequent to that I am willing to own the in-protocol
handler framework.

Here is the design I am convinced with after 3
iterations. I have considered all 
the requirements discussed in mailing list (especially
that of Danny, Noel, Stefano and Soren)


The framework contains classes- CommandHandler,
SMTPSession, SMTPProtocolHandler, SMTPOutputStream and
SMTPInputStream
A new XML configuration is also included.


                
____________________________________________________ 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com
I am Anagha Mudigonda, Graduate Student Polytechnic University New York.
I shall be implementing In-Protocol framework and Fast FAIL as a part of Google 
SOC and 
subsequent to that I am willing to own the in-protocol handler framework.

Here is the design I am convinced with after 3 iterations. I have considered 
all 
the requirements discussed in mailing list (especially that of Danny, Noel, 
Stefano and Soren)


The framework contains classes- CommandHandler, SMTPSession, 
SMTPProtocolHandler, SMTPOutputStream and SMTPInputStream
A new XML configuration is also included.


class CommandHandler
--------------------
Came up with a broad definition a commandHandler class
A Commandhandler class
1. registers to handle a command ( may process or validate the command 
arguments)
2. Registers to handler message (validate message or modify message header or 
body)

interface CommandHandler
{
 void init(String configStr); 
 void processCommand(String cmdString); 
 void setSMTPSession(SMTPSession session);
 void processMessage(Mail Obj); 
}

There can be more than one command handler registered for a command.
CommandHandlers can be registered to validate commands,  modify message.
CommandHandler's *process* methods can trigger events like message start , 
message end and message abort
and session end, session abort.


class SMTPSession
-----------------
The SMTP protocol session maintains the state information and ensures that 
the commands are executed in proper order. Also it provides controlled
access to I/O streams.

The SMTP session can be in one of the 4 states:
1. SESSION_START ( as soon as the client connects to server)
2. SESSION_END ( as soon as the client Sends QUIT command or closes connection)
3. MESSAGE_START ( as soon as the client issues MAIL FROM command)
4. MESSAGE_END ( as soon as the client sends message after DATA command)


class SMTPSession
{

 //Write Response
 void WriteResponse(String respString);

 //Register commandhandlers to command
 void registerCommandHandler(String cmdPrefix, CommandHandler cmdHandler);
 //Register commandhandlers to handle Message
 void registerMessageHandler(CommandHandler cmdHandler);

 //Command sequence handling
 void addCommandSequenceMap(string command, String[] predecessorCmds, string 
failMessage); //
 bool isCommandAllowed(String cmdString);


 //State information
 String getSender();
 String[] getRecepients();
 String setSender(String sender);
 String addRecepient(String recepient);
 String addRecepient(String[] recepients);
 String removeRecepient(String[] recepient);
 String removeRecepient(String recepient);

 //Message state modifier
 void startMessage(); 
 void endMessage(); 
 void abortMessage();

 //Message state modifier
 void endSession();
 void startSession();
 void abortSession();

 int getState(); //SESSION_START, SESSION_END, MESSAGE_BEGIN, MESSAGE_END

 void reset();

 SMTPInputStream getInputStream(); // object with no permission to close stream 
 
 SMTPOutputStream getOutputStream(); // Output stream object with no permission 
to close stream  
}


SMTPSession is per connection and is accessible to all commandhandlers.
If a command handler needs to modify the message, it registers with SMTPSession 
object.
And SMTPsession object registers after the message is received passes the 
message to 
all the registered commandhandlers for processing.



class SMTPProtocolHandler
-------------------------

implements the SMTPSession object.

class SMTPProtocolHandler implements SMTPSession
{
 //load all handlers and configure these
 //configure the command sequence
  
 //wait for SMTP connection
 //Create session state object
 //check if the command is allowed else respond with the failure message 

 //then loop thru the command handlers registered with the command and process 
the command

 //When Message end is triggered, call all the handlers registered for the 
message

}


XML Configuration
-----------------

   <smtpserver enabled="true">
      <!-- port 25 is the well-known/IANA registered port for SMTP -->
      <port>25</port>

      <!-- NEW CONFIGURATION -->

      <Protocolhandler class="org.apache.james.SMTPHandler">

         <Session class=org.apache.james.SMTPSession>
         <command name="MAIL" commandSequence="HELO,EHLO"/>
         <command name="RCPT" commandSequence="RCPT"/>
         <event sessionStartCommand=""/>
         <event sessionEndCommand="QUIT"/>
         <event MessageBeginCommand="MAIL"/>
         <event MessageEndCommand="DATA"/>
         </Session>

         <!-- registers with Protocol handler to handle "MAIL" command -->
         <CommandHandler class="org.apache.james.MAILCommandHandler">
          config..
         </CommandHandler>

         <!-- registers with protocol handler to handler "MAIL" command 
              also registers with protocol handler to handle Message 
(SPFhandler adds a SPF details into Message header)
         -->
         <CommandHandler name="MAIL" class="SPFHandler">
          config...
         </CommandHandler>

         <CommandHandler name="org.apache.james.RCPTCommandHandler">
          config
         </CommandHandler>

         <CommandHandler name="RecepientValidator">
          config
         </CommandHandler>

      </protocolhandler>
   </smtpserver>





Extending the framework
-----------------------

The framework can be extended in many ways

1. New commands can be added (for eg: STARTTLS)
   Add new command handlers and modifiying the config to include new command 
sequence.
   
2. New Validations (SPF validation)
   Add a new command handler.

3. Message Extensions
   Replace default command handler with a custom one.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to