Search in sources :

Example 1 with PlainAuthenticationHandlerFactory

use of org.subethamail.smtp.auth.PlainAuthenticationHandlerFactory in project vertx-examples by vert-x3.

the class LocalSmtpServer method startWithAuth.

public static void startWithAuth(int port) {
    SMTPServer server = new SMTPServer(new SimpleMessageListenerAdapter(new MyMessageListener()));
    server.setPort(port);
    UsernamePasswordValidator validator = (s, s1) -> {
        if (!"username".equalsIgnoreCase(s) || !"password".equalsIgnoreCase(s1)) {
            throw new LoginFailedException();
        }
    };
    server.setAuthenticationHandlerFactory(new PlainAuthenticationHandlerFactory(validator));
    server.start();
}
Also used : PlainAuthenticationHandlerFactory(org.subethamail.smtp.auth.PlainAuthenticationHandlerFactory) UsernamePasswordValidator(org.subethamail.smtp.auth.UsernamePasswordValidator) LoginFailedException(org.subethamail.smtp.auth.LoginFailedException) SMTPServer(org.subethamail.smtp.server.SMTPServer) SimpleMessageListenerAdapter(org.subethamail.smtp.helper.SimpleMessageListenerAdapter) UsernamePasswordValidator(org.subethamail.smtp.auth.UsernamePasswordValidator) PlainAuthenticationHandlerFactory(org.subethamail.smtp.auth.PlainAuthenticationHandlerFactory) LoginFailedException(org.subethamail.smtp.auth.LoginFailedException) SMTPServer(org.subethamail.smtp.server.SMTPServer) SimpleMessageListenerAdapter(org.subethamail.smtp.helper.SimpleMessageListenerAdapter)

Aggregations

LoginFailedException (org.subethamail.smtp.auth.LoginFailedException)1 PlainAuthenticationHandlerFactory (org.subethamail.smtp.auth.PlainAuthenticationHandlerFactory)1 UsernamePasswordValidator (org.subethamail.smtp.auth.UsernamePasswordValidator)1 SimpleMessageListenerAdapter (org.subethamail.smtp.helper.SimpleMessageListenerAdapter)1 SMTPServer (org.subethamail.smtp.server.SMTPServer)1