Class MailConfiguration
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.mail.MailConfiguration
@Configuration(proxyBeanMethods=false)
@EnableConfigurationProperties(MailProperties.class)
public class MailConfiguration
extends Object
Wires the SMTP implementation of
AccountMailer. The message source is private to the mailer, so it never
competes with the application's own MessageSource bean.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccountMailer(org.springframework.mail.javamail.JavaMailSender mailSender, MailProperties properties) Creates the mailer.emailOttDelivery(org.springframework.mail.javamail.JavaMailSender mailSender, MailProperties properties) Creates the e-mail one-time token delivery.(package private) static org.springframework.context.MessageSourceBuilds the message source of the mailer.(package private) static org.springframework.context.MessageSourceBuilds the message source of the one-time token e-mails.(package private) static org.thymeleaf.TemplateEngineottTemplateEngine(org.springframework.context.MessageSource messages) Builds the private Thymeleaf engine of the one-time token e-mails: HTML mode formail/*.html, text mode formail/*.txt, both from the classpath.private static org.thymeleaf.templateresolver.ClassLoaderTemplateResolverBuilds a classpath resolver for the templates matching a pattern.
-
Field Details
-
BUNDLE
Base name of the message bundles of this module.- See Also:
-
OTT_BUNDLE
Base name of the message bundle of the one-time token e-mails.- See Also:
-
-
Constructor Details
-
MailConfiguration
public MailConfiguration()
-
-
Method Details
-
accountMailer
@Bean public AccountMailer accountMailer(org.springframework.mail.javamail.JavaMailSender mailSender, MailProperties properties) Creates the mailer.- Parameters:
mailSender- Spring Mail sender configured byspring.mail.*.properties- sender, base URL and locale.- Returns:
- the account mailer.
-
emailOttDelivery
@Bean public OttDelivery emailOttDelivery(org.springframework.mail.javamail.JavaMailSender mailSender, MailProperties properties) Creates the e-mail one-time token delivery. Its Thymeleaf engine is built here and deliberately not exposed as a bean, because aTemplateEnginebean would replace the one of the web pages.- Parameters:
mailSender- Spring Mail sender configured byspring.mail.*.properties- sender, base URL and locale.- Returns:
- the e-mail delivery of one-time tokens.
-
ottMessages
static org.springframework.context.MessageSource ottMessages()Builds the message source of the one-time token e-mails.- Returns:
- a source over
mail/ott-mailthat never falls back to the platform's locale.
-
ottTemplateEngine
static org.thymeleaf.TemplateEngine ottTemplateEngine(org.springframework.context.MessageSource messages) Builds the private Thymeleaf engine of the one-time token e-mails: HTML mode formail/*.html, text mode formail/*.txt, both from the classpath.- Parameters:
messages- source of the texts referenced by the templates.- Returns:
- the engine.
-
resolver
private static org.thymeleaf.templateresolver.ClassLoaderTemplateResolver resolver(String pattern, org.thymeleaf.templatemode.TemplateMode mode, int order) Builds a classpath resolver for the templates matching a pattern.- Parameters:
pattern- resolvable template names.mode- template mode.order- position among the resolvers.- Returns:
- the resolver.
-
mailMessages
static org.springframework.context.MessageSource mailMessages()Builds the message source of the mailer.- Returns:
- a source over the module's bundles that never falls back to the platform's locale.
-