org.subethamail.smtp.auth
Class PluginAuthenticationHandler

java.lang.Object
  extended by org.subethamail.smtp.auth.PluginAuthenticationHandler
All Implemented Interfaces:
AuthenticationHandler

public class PluginAuthenticationHandler
extends java.lang.Object
implements AuthenticationHandler

This handler makes it possible to sum the capabilities of two or more handlers types.
Hence, you can design a single handler for each authentication mechanism and decide how many authentication mechanisms to support by simply plugging them here.

Author:
Marco Trevisan

Constructor Summary
PluginAuthenticationHandler()
          Creates a new instance of PluginAuthenticationHandler
 
Method Summary
 void addPlugin(AuthenticationHandler plugin)
           
 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]".
 AuthenticationHandler getActiveHandler()
           
 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.List<AuthenticationHandler> getPlugins()
           
 void resetState()
          Since a so-designed handler has its own state, it seems reasonable to enable resetting its state.
 void setActiveHandler(AuthenticationHandler activeHandler)
           
 void setPlugins(java.util.List<AuthenticationHandler> plugins)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginAuthenticationHandler

public PluginAuthenticationHandler()
Creates a new instance of PluginAuthenticationHandler

Method Detail

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.

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

getPlugins

public java.util.List<AuthenticationHandler> getPlugins()

addPlugin

public void addPlugin(AuthenticationHandler plugin)

setPlugins

public void setPlugins(java.util.List<AuthenticationHandler> plugins)

getActiveHandler

public AuthenticationHandler getActiveHandler()

setActiveHandler

public void setActiveHandler(AuthenticationHandler activeHandler)


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