SK.gnome.dwarf.mail.smtp.proc.agent
Class MessageSyntax

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.GenericServer
          extended bySK.gnome.dwarf.thread.ThreadServer
              extended bySK.gnome.dwarf.mail.smtp.proc.MailAgent
                  extended bySK.gnome.dwarf.mail.smtp.proc.agent.MessageCheck
                      extended bySK.gnome.dwarf.mail.smtp.proc.agent.MessageSyntax
All Implemented Interfaces:
Preprocessing, SK.gnome.dwarf.Reportable, java.lang.Runnable, SK.gnome.dwarf.Server, SK.gnome.dwarf.Service
Direct Known Subclasses:
AntiSpam

public class MessageSyntax
extends MessageCheck

Provides an agent for basic message syntax checking.

It is able to check the message header, MIME body parts and the correct format of internet addresses used in the header.


Field Summary
 
Fields inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
context, required
 
Fields inherited from class SK.gnome.dwarf.thread.ThreadServer
daemon, thread
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
MessageSyntax(java.lang.String name)
           
 
Method Summary
protected  void checkMimePart(MailAgentMessage message, java.util.Collection recipients, MimePart part)
          Checks the MIME body part.
protected  void preprocess(MailAgentMessage message, java.util.Collection recipients)
          Processes the message.
 void setCheckAddresses(boolean enable)
          Enables checking of the internet addresses.
 void setCheckBody(boolean enable)
          Enables checking of the MIME body parts.
 void setCheckHeaders(boolean enable)
          Enables checking of the message header.
 void setMaxMessageHops(int limit)
          Sets the maximum limit for the message hops.
 
Methods inherited from class SK.gnome.dwarf.mail.smtp.proc.agent.MessageCheck
fail, fail, init, setFailedState, setStoreTo
 
Methods inherited from class SK.gnome.dwarf.mail.smtp.proc.MailAgent
destroy, filter, init, isRequired, postprocess, setRequired, storeMessage
 
Methods inherited from class SK.gnome.dwarf.thread.ThreadServer
enableThread, finish, loop, run, setDaemon, shutdown, start, stop
 
Methods inherited from class SK.gnome.dwarf.GenericServer
addService, addService, getAuthenticator, getLogger, getParameters, getService, getServices, getServices, removeService, report
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface SK.gnome.dwarf.Service
getFullName, getName, getState, log, log, login, logout
 

Constructor Detail

MessageSyntax

public MessageSyntax(java.lang.String name)
Method Detail

setCheckHeaders

public void setCheckHeaders(boolean enable)
Enables checking of the message header.

If enabled, the message header is parsed and tested if it contains the required "From" and "Date" headers.

Parameters:
enable - true to enable the header checking, false otherwise

setCheckAddresses

public void setCheckAddresses(boolean enable)
Enables checking of the internet addresses.

If enabled, the "From", "Sender", "Reply-To", "To", "Cc" and "BCc" headers are checked for the correct syntax of the RFC822 addresses.

Parameters:
enable - true to enable the address checking, false otherwise

setCheckBody

public void setCheckBody(boolean enable)
Enables checking of the MIME body parts.

If enabled, the message is checked is all its MIME body parts are correctly formatted.

Parameters:
enable - true to enable the MIME checking, false otherwise

setMaxMessageHops

public void setMaxMessageHops(int limit)
Sets the maximum limit for the message hops.

A non-zero value sets the maximum number of "Received" headers in a single message.

Parameters:
limit - the message hops limit

preprocess

protected void preprocess(MailAgentMessage message,
                          java.util.Collection recipients)
                   throws java.io.IOException,
                          MailException
Description copied from class: MailAgent
Processes the message.

This method is called on the agent only once for each message, just after it has arrived to the mail queue. In order to let this happen, the agent must implement the Preprocessing interface.

The recipients argument is a collection of Recipient objects representing the message recipients, as returned after processing by the mail filter chain. This collection is always non-empty.

Overrides:
preprocess in class MailAgent
Parameters:
message - the queued message
recipients - collection of recipients
Throws:
MailException - if an error occured
java.io.IOException - if an I/O error occured

checkMimePart

protected void checkMimePart(MailAgentMessage message,
                             java.util.Collection recipients,
                             MimePart part)
                      throws java.io.IOException,
                             MailException
Checks the MIME body part.

This method checks a single MIME body part. It may be overriden to include an additional checking operation.

By default it iterates over the nested MIME body parts of the given part and calls checkMimePart for each one.

Parameters:
message - the checked message
recipients - the recipient collection
part - the checked MIME body part
Throws:
MimeException - if a mime format error occured
java.io.IOException - if an I/O error occured
MailException - if another error occured
FailedDeliveryException - if the message fails


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.