org.subethamail.smtp.auth
Class LoginAuthenticationHandler

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

public class LoginAuthenticationHandler
extends java.lang.Object
implements AuthenticationHandler

Implements the SMTP AUTH LOGIN mechanism.
You are only required to plug your UsernamePasswordValidator implementation for username and password validation to take effect.

Author:
Marco Trevisan

Constructor Summary
LoginAuthenticationHandler(UsernamePasswordValidator helper)
          Creates a new instance of LoginAuthenticationHandler
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoginAuthenticationHandler

public LoginAuthenticationHandler(UsernamePasswordValidator helper)
Creates a new instance of LoginAuthenticationHandler

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


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