com.github.sleroy.junit.mail.server.SMTPAuthHandlerFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fakesmtp-junit-runner Show documentation
Show all versions of fakesmtp-junit-runner Show documentation
JUnit Rule to create a FakeSmtp server to write mailing integration tests
/*
*
*/
package com.github.sleroy.junit.mail.server;
import java.util.ArrayList;
import java.util.List;
import org.subethamail.smtp.AuthenticationHandler;
import org.subethamail.smtp.AuthenticationHandlerFactory;
/**
* The factory interface for creating authentication handlers.
*
* @author jasonpenny
* @since 1.2
*/
final class SMTPAuthHandlerFactory implements AuthenticationHandlerFactory {
/** The Constant LOGIN_MECHANISM. */
public static final String LOGIN_MECHANISM = "LOGIN";
/** The smtp auth handler. */
private final AuthenticationHandler smtpAuthHandler;
/**
* Instantiates a new SMTP auth handler factory.
*
* @param smtpAuthHandler
* the smtp auth handler
*/
public SMTPAuthHandlerFactory(final AuthenticationHandler smtpAuthHandler) {
super();
this.smtpAuthHandler = smtpAuthHandler;
}
/*
* (non-Javadoc)
*
* @see org.subethamail.smtp.AuthenticationHandlerFactory#create()
*/
@Override
public AuthenticationHandler create() {
return smtpAuthHandler;
}
/*
* (non-Javadoc)
*
* @see org.subethamail.smtp.AuthenticationHandlerFactory#
* getAuthenticationMechanisms()
*/
@Override
public List getAuthenticationMechanisms() {
final List result = new ArrayList<>();
result.add(SMTPAuthHandlerFactory.LOGIN_MECHANISM);
return result;
}
}