org.abstracthorizon.mercury.smtp.command
Class DataCommand

java.lang.Object
  extended by org.abstracthorizon.mercury.smtp.command.SMTPCommand
      extended by org.abstracthorizon.mercury.smtp.command.DataCommand
All Implemented Interfaces:
org.abstracthorizon.danube.connection.ConnectionHandler
Direct Known Subclasses:
FilterDataCommand, QuietFilterDataCommand

public class DataCommand
extends SMTPCommand

SMTP DATA command.

Author:
Daniel Sendula

Field Summary
protected static byte[] CRLF
           
static SimpleDateFormat format
           
protected static org.slf4j.Logger logger
           
static javax.mail.Session mailSession
           
 
Constructor Summary
DataCommand()
          Constructor
 
Method Summary
protected  void append(StringBuffer buf, String part)
          Appends elements to header value making it sure it is not over 999 chars.
protected  String composeDestMailboxes(List<Path> dest)
          Composes Received header's list of destination mailboxes
protected  String composeReceivedHeader(SMTPSession connection)
          Adds "Received:" header.
protected  void execute(SMTPSession connection)
          Executed the command
protected  String getTCPInfo(Socket socket)
          Returns inet address as string
protected  boolean postcheck(SMTPSession connection)
          Returns true
protected  void postProcessing(SMTPSession connection, boolean hasSuccessfuls)
          Sets positive response if there are successful mailboxes
protected  boolean precheck(SMTPSession connection)
          Returns true in case it is ok with proceeding with the reading input stream.
protected  boolean processExternalMail(SMTPSession connection, List<Path> externals, javax.mail.internet.MimeMessage message)
          Processes external mails - invokes transport protocol in sending mail further or caching it localing for delayed send.
protected  boolean processLocalMailbox(SMTPSession connection, Path path, javax.mail.internet.MimeMessage message)
          Processes local storage mails.
protected  void processMail(SMTPSession connection, javax.mail.internet.MimeMessage message)
          Processes mail.
protected  void readExtraParameters(SMTPSession connection, SMTPScanner scanner)
          Obtains extra parameters.
protected  void readMail(InputStream in, OutputStream mail)
          Reads raw mail from the input stream.
 
Methods inherited from class org.abstracthorizon.mercury.smtp.command.SMTPCommand
handleConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRLF

protected static final byte[] CRLF

format

public static final SimpleDateFormat format

logger

protected static final org.slf4j.Logger logger

mailSession

public static javax.mail.Session mailSession
Constructor Detail

DataCommand

public DataCommand()
Constructor

Method Detail

execute

protected void execute(SMTPSession connection)
                throws CommandException,
                       IOException,
                       ParserException
Executed the command

Specified by:
execute in class SMTPCommand
Parameters:
connection - smtp session
Throws:
CommandException
IOException
ParserException

composeReceivedHeader

protected String composeReceivedHeader(SMTPSession connection)
                                throws IOException
Adds "Received:" header.

Parameters:
connection - SMTP session
Throws:
IOException - io exception

getTCPInfo

protected String getTCPInfo(Socket socket)
Returns inet address as string

Parameters:
socket - socket
Returns:
string representation of a string

composeDestMailboxes

protected String composeDestMailboxes(List<Path> dest)
Composes Received header's list of destination mailboxes

Parameters:
dest - list of mailboxes
Returns:
string representation of 's list of destination mailboxes

append

protected void append(StringBuffer buf,
                      String part)
Appends elements to header value making it sure it is not over 999 chars.

Parameters:
buf - buffer to append to
part - new elemnt to added to header value

readMail

protected void readMail(InputStream in,
                        OutputStream mail)
                 throws IOException
Reads raw mail from the input stream.
Method to be overriden for DATA extensions.

Parameters:
in - input stream mail is read from. Usually input stream from the socket
mail - output stream mail is written to
Throws:
IOException - in case of an exception while reading mail

readExtraParameters

protected void readExtraParameters(SMTPSession connection,
                                   SMTPScanner scanner)
                            throws IOException,
                                   ParserException,
                                   CommandException
Obtains extra parameters.
Method to be overriden for DATA extensions.

Parameters:
session - SMTP session
scanner - STMP scanner
Throws:
IOException - io exception
ParserException - parsing exception
CommandException - command exception

precheck

protected boolean precheck(SMTPSession connection)
                    throws CommandException,
                           IOException
Returns true in case it is ok with proceeding with the reading input stream. This method is responsible of sending response back to the client
Method to be overriden for filtering purposes.

Parameters:
session - SMTP session
Returns:
true in case it is ok with proceeding with the reading input stream.
Throws:
IOException
CommandException

postcheck

protected boolean postcheck(SMTPSession connection)
                     throws IOException
Returns true

Parameters:
connection - smtp session
Returns:
true
Throws:
IOException

postProcessing

protected void postProcessing(SMTPSession connection,
                              boolean hasSuccessfuls)
                       throws IOException
Sets positive response if there are successful mailboxes

Parameters:
connection - smtp session
hasSuccessfuls - has successful mailboxes
Throws:
IOException

processMail

protected void processMail(SMTPSession connection,
                           javax.mail.internet.MimeMessage message)
                    throws IOException
Processes mail.

Parameters:
connection - SMTP session
message - mime message
Throws:
IOException - needed for sending responses

processLocalMailbox

protected boolean processLocalMailbox(SMTPSession connection,
                                      Path path,
                                      javax.mail.internet.MimeMessage message)
Processes local storage mails.

Parameters:
connection - SMTP session
path - path object
message - message
Returns:
true in case it succeded

processExternalMail

protected boolean processExternalMail(SMTPSession connection,
                                      List<Path> externals,
                                      javax.mail.internet.MimeMessage message)
Processes external mails - invokes transport protocol in sending mail further or caching it localing for delayed send.

Parameters:
connection - smtp session
externals - list of Path objects
message - mime message to be forwarded
Returns:
true in case it succeded


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.