org.subethamail.smtp
Interface AuthenticationHandler

All Known Subinterfaces:
MessageHandler
All Known Implementing Classes:
AbstractMessageHandler, DefaultMessageHandler, DummyAuthenticationHandler, LoginAuthenticationHandler, PlainAuthenticationHandler, PluginAuthenticationHandler

public interface AuthenticationHandler

The interface that enables challenge-response communication necessary for SMTP AUTH.

Since the authentication process can be stateful, an instance of this class can be stateful too.
Do not share a single instance of this interface if you don't explicitly need to do so.

Author:
Marco Trevisan

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.
 void resetState()
          Since a so-designed handler has its own state, it seems reasonable to enable resetting its state.
 

Method Detail

getAuthenticationMechanisms

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.
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.

Returns:
the supported authentication mechanisms as List.

auth

boolean auth(java.lang.String clientInput,
             java.lang.StringBuilder response,
             ConnectionContext ctx)
             throws RejectException
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

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

void resetState()
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.



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