org.apache.james.smtpserver
Class SMTPHandler

java.lang.Object
  extended by org.apache.james.smtpserver.SMTPHandler
All Implemented Interfaces:
SMTPSession, ProtocolHandler

public class SMTPHandler
extends java.lang.Object
implements ProtocolHandler, SMTPSession

Provides SMTP functionality by carrying out the server side of the SMTP interaction.

Version:
CVS $Revision: 717869 $ $Date: 2008-11-15 15:56:18 +0000 (Sat, 15 Nov 2008) $

Field Summary
 
Fields inherited from interface org.apache.james.smtpserver.SMTPSession
CURRENT_HELO_MODE, CURRENT_HELO_NAME, CURRENT_RECIPIENT, MESG_FAILED, RCPT_LIST, SENDER
 
Constructor Summary
SMTPHandler()
           
 
Method Summary
 void abortMessage()
          this makes the message to be dropped inprotocol
 java.lang.String clearResponseBuffer()
          Clears the response buffer, returning the String of characters in the buffer.
 void endSession()
          this makes the session to close
 void errorHandler(java.lang.RuntimeException e)
          Provides errorHandling
 java.lang.String getCommandArgument()
          Returns currently process command argument
 java.lang.String getCommandName()
          Returns currently process command name
 SMTPHandlerConfigurationData getConfigurationData()
          Returns SMTPHandler service wide configuration
 java.util.Map getConnectionState()
          Returns Map that consists of the state of the SMTPSession per connection
 java.io.InputStream getInputStream()
          Returns Inputstream for handling messages and commands
 org.apache.mailet.Mail getMail()
          Returns Mail object for message handlers to process
 int getRcptCount()
          Returns the recipient count
 java.lang.String getRemoteHost()
          Returns host name of the client
 java.lang.String getRemoteIPAddress()
          Returns host ip address of the client
 java.lang.StringBuffer getResponseBuffer()
          Returns ResponseBuffer, this optimizes the unecessary creation of resources by each handler object
 java.lang.String getSessionID()
          Returns the SMTP session id
 java.util.Map getState()
          Returns Map that consists of the state of the SMTPSession per mail
 boolean getStopHandlerProcessing()
          Return if handlerprocessing should be stopped
 java.lang.String getUser()
          Returns the user name associated with this SMTP interaction.
 Watchdog getWatchdog()
          Returns Watchdog object used for handling timeout
 void handleProtocol()
          Handle the protocol
 boolean isAuthRequired()
          Returns whether Authentication is required or not
 boolean isRelayingAllowed()
          Returns whether Relaying is allowed or not
 boolean isSessionEnded()
          Returns the session status
 java.lang.String readCommandLine()
          Reads a line of characters off the command line.
 void resetConnectionState()
          Reset the Connection state
 void resetHandler()
          Resets the handler data to a basic state.
 void resetState()
          Resets message-specific, but not authenticated user, state.
 void setConfigurationData(java.lang.Object theData)
          Set the configuration data for the handler
 void setHandlerChain(SMTPHandlerChain handlerChain)
          Sets the SMTPHandlerChain
 void setMail(org.apache.mailet.Mail mail)
          Sets the MailImpl object for further processing
 void setProtocolHandlerHelper(ProtocolHandlerHelper phh)
          Injects the ProtocolHandlerHelper service
 void setRelayingAllowed(boolean relayingAllowed)
          Set if reallying is allowed
 void setStopHandlerProcessing(boolean stopHandlerProcessing)
          Set to true if the handlerprocessing should be stopped
 void setUser(java.lang.String userID)
          Sets the user name associated with this SMTP interaction.
 boolean useHeloEhloEnforcement()
          Returns whether remote server needs to send HELO/EHLO
 void writeResponse(java.lang.String respString)
          Writes response string to the client
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SMTPHandler

public SMTPHandler()
Method Detail

setConfigurationData

public void setConfigurationData(java.lang.Object theData)
Set the configuration data for the handler

Specified by:
setConfigurationData in interface ProtocolHandler
Parameters:
theData - the per-service configuration data for this handler

handleProtocol

public void handleProtocol()
                    throws java.io.IOException
Description copied from interface: ProtocolHandler
Handle the protocol

Specified by:
handleProtocol in interface ProtocolHandler
Throws:
java.io.IOException - get thrown if an IO error is detected
See Also:
AbstractJamesHandler.handleProtocol()

resetHandler

public void resetHandler()
Resets the handler data to a basic state.

Specified by:
resetHandler in interface ProtocolHandler

setHandlerChain

public void setHandlerChain(SMTPHandlerChain handlerChain)
Sets the SMTPHandlerChain

Parameters:
handlerChain - SMTPHandler object

writeResponse

public void writeResponse(java.lang.String respString)
Description copied from interface: SMTPSession
Writes response string to the client

Specified by:
writeResponse in interface SMTPSession
Parameters:
respString - String that needs to send to the client
See Also:
SMTPSession.writeResponse(String)

getCommandName

public java.lang.String getCommandName()
Description copied from interface: SMTPSession
Returns currently process command name

Specified by:
getCommandName in interface SMTPSession
Returns:
current command name
See Also:
SMTPSession.getCommandName()

getCommandArgument

public java.lang.String getCommandArgument()
Description copied from interface: SMTPSession
Returns currently process command argument

Specified by:
getCommandArgument in interface SMTPSession
Returns:
current command argument
See Also:
SMTPSession.getCommandArgument()

getMail

public org.apache.mailet.Mail getMail()
Description copied from interface: SMTPSession
Returns Mail object for message handlers to process

Specified by:
getMail in interface SMTPSession
Returns:
Mail object
See Also:
SMTPSession.getMail()

setMail

public void setMail(org.apache.mailet.Mail mail)
Description copied from interface: SMTPSession
Sets the MailImpl object for further processing

Specified by:
setMail in interface SMTPSession
Parameters:
mail - MailImpl object
See Also:
SMTPSession.setMail(Mail)

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: SMTPSession
Returns host name of the client

Specified by:
getRemoteHost in interface SMTPSession
Returns:
hostname of the client
See Also:
SMTPSession.getRemoteHost()

getRemoteIPAddress

public java.lang.String getRemoteIPAddress()
Description copied from interface: SMTPSession
Returns host ip address of the client

Specified by:
getRemoteIPAddress in interface SMTPSession
Returns:
host ip address of the client
See Also:
SMTPSession.getRemoteIPAddress()

endSession

public void endSession()
Description copied from interface: SMTPSession
this makes the session to close

Specified by:
endSession in interface SMTPSession
See Also:
SMTPSession.endSession()

isSessionEnded

public boolean isSessionEnded()
Description copied from interface: SMTPSession
Returns the session status

Specified by:
isSessionEnded in interface SMTPSession
Returns:
if the session is open or closed
See Also:
SMTPSession.isSessionEnded()

resetState

public void resetState()
Description copied from interface: SMTPSession
Resets message-specific, but not authenticated user, state.

Specified by:
resetState in interface SMTPSession
See Also:
SMTPSession.resetState()

getState

public java.util.Map getState()
Description copied from interface: SMTPSession
Returns Map that consists of the state of the SMTPSession per mail

Specified by:
getState in interface SMTPSession
Returns:
map of the current SMTPSession state per mail
See Also:
SMTPSession.getState()

getConfigurationData

public SMTPHandlerConfigurationData getConfigurationData()
Description copied from interface: SMTPSession
Returns SMTPHandler service wide configuration

Specified by:
getConfigurationData in interface SMTPSession
Returns:
SMTPHandlerConfigurationData
See Also:
SMTPSession.getConfigurationData()

isRelayingAllowed

public boolean isRelayingAllowed()
Description copied from interface: SMTPSession
Returns whether Relaying is allowed or not

Specified by:
isRelayingAllowed in interface SMTPSession
Returns:
the relaying status
See Also:
SMTPSession.isRelayingAllowed()

setRelayingAllowed

public void setRelayingAllowed(boolean relayingAllowed)
Description copied from interface: SMTPSession
Set if reallying is allowed

Specified by:
setRelayingAllowed in interface SMTPSession
See Also:
SMTPSession.setRelayingAllowed(boolean relayingAllowed)

isAuthRequired

public boolean isAuthRequired()
Description copied from interface: SMTPSession
Returns whether Authentication is required or not

Specified by:
isAuthRequired in interface SMTPSession
Returns:
authentication required or not
See Also:
SMTPSession.isAuthRequired()

useHeloEhloEnforcement

public boolean useHeloEhloEnforcement()
Description copied from interface: SMTPSession
Returns whether remote server needs to send HELO/EHLO

Specified by:
useHeloEhloEnforcement in interface SMTPSession
Returns:
HELO/EHLO required or not
See Also:
SMTPSession.useHeloEhloEnforcement()

getUser

public java.lang.String getUser()
Description copied from interface: SMTPSession
Returns the user name associated with this SMTP interaction.

Specified by:
getUser in interface SMTPSession
Returns:
the user name
See Also:
SMTPSession.getUser()

setUser

public void setUser(java.lang.String userID)
Description copied from interface: SMTPSession
Sets the user name associated with this SMTP interaction.

Specified by:
setUser in interface SMTPSession
Parameters:
userID - the user name
See Also:
SMTPSession.setUser(String)

getResponseBuffer

public java.lang.StringBuffer getResponseBuffer()
Description copied from interface: SMTPSession
Returns ResponseBuffer, this optimizes the unecessary creation of resources by each handler object

Specified by:
getResponseBuffer in interface SMTPSession
Returns:
responseBuffer
See Also:
SMTPSession.getResponseBuffer()

clearResponseBuffer

public java.lang.String clearResponseBuffer()
Description copied from interface: SMTPSession
Clears the response buffer, returning the String of characters in the buffer.

Specified by:
clearResponseBuffer in interface SMTPSession
Returns:
the data in the response buffer
See Also:
SMTPSession.clearResponseBuffer()

readCommandLine

public final java.lang.String readCommandLine()
                                       throws java.io.IOException
Description copied from interface: SMTPSession
Reads a line of characters off the command line.

Specified by:
readCommandLine in interface SMTPSession
Returns:
the trimmed input line
Throws:
java.io.IOException - if an exception is generated reading in the input characters
See Also:
SMTPSession.readCommandLine()

getWatchdog

public Watchdog getWatchdog()
Description copied from interface: SMTPSession
Returns Watchdog object used for handling timeout

Specified by:
getWatchdog in interface SMTPSession
Returns:
Watchdog object
See Also:
SMTPSession.getWatchdog()

getInputStream

public java.io.InputStream getInputStream()
Description copied from interface: SMTPSession
Returns Inputstream for handling messages and commands

Specified by:
getInputStream in interface SMTPSession
Returns:
InputStream object
See Also:
SMTPSession.getInputStream()

getSessionID

public java.lang.String getSessionID()
Description copied from interface: SMTPSession
Returns the SMTP session id

Specified by:
getSessionID in interface SMTPSession
Returns:
SMTP session id
See Also:
SMTPSession.getSessionID()

abortMessage

public void abortMessage()
Description copied from interface: SMTPSession
this makes the message to be dropped inprotocol

Specified by:
abortMessage in interface SMTPSession
See Also:
SMTPSession.abortMessage()

getRcptCount

public int getRcptCount()
Description copied from interface: SMTPSession
Returns the recipient count

Specified by:
getRcptCount in interface SMTPSession
Returns:
recipient count
See Also:
SMTPSession.getRcptCount()

setStopHandlerProcessing

public void setStopHandlerProcessing(boolean stopHandlerProcessing)
Description copied from interface: SMTPSession
Set to true if the handlerprocessing should be stopped

Specified by:
setStopHandlerProcessing in interface SMTPSession
Parameters:
stopHandlerProcessing - true or false
See Also:
SMTPSession.setStopHandlerProcessing(boolean)

getStopHandlerProcessing

public boolean getStopHandlerProcessing()
Description copied from interface: SMTPSession
Return if handlerprocessing should be stopped

Specified by:
getStopHandlerProcessing in interface SMTPSession
Returns:
true or false
See Also:
SMTPSession.getStopHandlerProcessing()

resetConnectionState

public void resetConnectionState()
Description copied from interface: SMTPSession
Reset the Connection state

Specified by:
resetConnectionState in interface SMTPSession

getConnectionState

public java.util.Map getConnectionState()
Description copied from interface: SMTPSession
Returns Map that consists of the state of the SMTPSession per connection

Specified by:
getConnectionState in interface SMTPSession
Returns:
map of the current SMTPSession state per connection

setProtocolHandlerHelper

public void setProtocolHandlerHelper(ProtocolHandlerHelper phh)
Description copied from interface: ProtocolHandler
Injects the ProtocolHandlerHelper service

Specified by:
setProtocolHandlerHelper in interface ProtocolHandler
Parameters:
phh - service

errorHandler

public void errorHandler(java.lang.RuntimeException e)
Description copied from interface: ProtocolHandler
Provides errorHandling

Specified by:
errorHandler in interface ProtocolHandler
Parameters:
e - exception


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.