org.subethamail.smtp.server
Class AbstractMessageHandler

java.lang.Object
  extended by org.subethamail.smtp.server.AbstractMessageHandler
All Implemented Interfaces:
AuthenticationHandler, MessageHandler
Direct Known Subclasses:
DefaultMessageHandler

public abstract class AbstractMessageHandler
extends java.lang.Object
implements MessageHandler

A simple base class to make implementing message handlers easier. It also makes modification of the interface class easier on users.

Author:
Jeff Schnitzer, De Oliveira Edouard <doe_wanted@yahoo.fr>

Field Summary
static char[] SMTP_TERMINATOR
           
 
Constructor Summary
protected AbstractMessageHandler(MessageContext ctx, AuthenticationHandler authHandler)
           
 
Method Summary
 boolean auth(java.lang.String clientInput, java.lang.StringBuilder response, ConnectionContext ctx)
          Initially called using an input string in the RFC2554 form: "AUTH [initial-response]".
 java.util.List<java.lang.String> getAuthenticationMechanisms()
          If your handler supports RFC 2554 at some degree, then it must return all the supported mechanisms here.
 java.util.Collection<MessageListener> getListeners()
           
 java.io.InputStream getPrivateInputStream(boolean useCopy, java.io.InputStream data)
          Provides a private unstuffed InputStream for each invocation unless useCopy is false in which case the data stream is unstuffed and returned.
 void resetState()
          Since a so-designed handler has its own state, it seems reasonable to enable resetting its state.
protected  void setListeners(java.util.Collection<MessageListener> listeners)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.subethamail.smtp.MessageHandler
data, from, recipient, resetMessageState
 

Field Detail

SMTP_TERMINATOR

public static final char[] SMTP_TERMINATOR
Constructor Detail

AbstractMessageHandler

protected AbstractMessageHandler(MessageContext ctx,
                                 AuthenticationHandler authHandler)
Method Detail

setListeners

protected void setListeners(java.util.Collection<MessageListener> listeners)

getListeners

public java.util.Collection<MessageListener> getListeners()

getPrivateInputStream

public java.io.InputStream getPrivateInputStream(boolean useCopy,
                                                 java.io.InputStream data)
Provides a private unstuffed InputStream for each invocation unless useCopy is false in which case the data stream is unstuffed and returned. Unstuffing is made by encapsulating the stream within special streams.

See Also:
CharTerminatedInputStream, DotUnstuffingInputStream

auth

public boolean auth(java.lang.String clientInput,
                    java.lang.StringBuilder response,
                    ConnectionContext ctx)
             throws RejectException
Description copied from interface: AuthenticationHandler
Initially called using an input string in the RFC2554 form: "AUTH [initial-response]".
This method must provide the correct reply (by filling the response parameter) at each clientInput.

Depending on the authentication mechanism, the handshaking process may require many request-response passes. This method will return true only when the authentication process is finished

Specified by:
auth in interface AuthenticationHandler
Parameters:
clientInput - The client's input.
response - a buffer filled with your response to the client input.
ctx - the connection context filled with the credential of the user if authentication succeeds.
Returns:
true if the authentication process is finished, false otherwise.
Throws:
RejectException - if authentication fails.

resetState

public void resetState()
Description copied from interface: AuthenticationHandler
Since a so-designed handler has its own state, it seems reasonable to enable resetting its state. This can be done, for example, after a "*" client response during the AUTH command processing.

Specified by:
resetState in interface AuthenticationHandler

getAuthenticationMechanisms

public java.util.List<java.lang.String> getAuthenticationMechanisms()
Description copied from interface: AuthenticationHandler
If your handler supports RFC 2554 at some degree, then it must return all the supported mechanisms here.
The order you use to populate the list will be preserved in the output of the EHLO command.
If your handler does not support RFC 2554 at all, return an empty list.

Specified by:
getAuthenticationMechanisms in interface AuthenticationHandler
Returns:
the supported authentication mechanisms as List.


Copyright © 2011 SubEthaSMTP. All Rights Reserved. Build version: UNVERSIONED