public class FreeMarkerEmailTemplateProvider extends Object implements EmailTemplateProvider
Modifier and Type | Class and Description |
---|---|
protected class |
FreeMarkerEmailTemplateProvider.EmailTemplate |
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
attributes |
protected AuthenticationSessionModel |
authenticationSession
authenticationSession can be null for some email sendings, it is filled only for email sendings performed as part of the authentication session (email verification, password reset, broker link
etc.)!
|
protected FreeMarkerUtil |
freeMarker |
protected RealmModel |
realm |
protected KeycloakSession |
session |
protected UserModel |
user |
IDENTITY_PROVIDER_BROKER_CONTEXT
Constructor and Description |
---|
FreeMarkerEmailTemplateProvider(KeycloakSession session,
FreeMarkerUtil freeMarker) |
Modifier and Type | Method and Description |
---|---|
protected void |
addLinkInfoIntoAttributes(String link,
long expirationInMinutes,
Map<String,Object> attributes)
Add link info into template attributes.
|
void |
close() |
protected String |
getRealmName() |
protected Theme |
getTheme() |
protected FreeMarkerEmailTemplateProvider.EmailTemplate |
processTemplate(String subjectKey,
List<Object> subjectAttributes,
String template,
Map<String,Object> attributes) |
protected void |
send(Map<String,String> config,
String subject,
String textBody,
String htmlBody) |
void |
send(String subjectFormatKey,
List<Object> subjectAttributes,
String bodyTemplate,
Map<String,Object> bodyAttributes)
Send formatted email
|
void |
send(String subjectFormatKey,
String bodyTemplate,
Map<String,Object> bodyAttributes)
Send formatted email
|
protected void |
send(String subject,
String textBody,
String htmlBody) |
void |
sendConfirmIdentityBrokerLink(String link,
long expirationInMinutes)
Send to confirm that user wants to link his account with identity broker link
|
void |
sendEvent(Event event) |
void |
sendExecuteActions(String link,
long expirationInMinutes)
Change password email requested by admin
|
void |
sendPasswordReset(String link,
long expirationInMinutes)
Reset password sent from forgot password link on login
|
void |
sendSmtpTestEmail(Map<String,String> config,
UserModel user)
Test SMTP connection with current logged in user
|
void |
sendVerifyEmail(String link,
long expirationInMinutes) |
EmailTemplateProvider |
setAttribute(String name,
Object value) |
EmailTemplateProvider |
setAuthenticationSession(AuthenticationSessionModel authenticationSession) |
EmailTemplateProvider |
setRealm(RealmModel realm) |
EmailTemplateProvider |
setUser(UserModel user) |
protected String |
toCamelCase(EventType event) |
protected KeycloakSession session
protected AuthenticationSessionModel authenticationSession
protected FreeMarkerUtil freeMarker
protected RealmModel realm
protected UserModel user
public FreeMarkerEmailTemplateProvider(KeycloakSession session, FreeMarkerUtil freeMarker)
public EmailTemplateProvider setRealm(RealmModel realm)
setRealm
in interface EmailTemplateProvider
public EmailTemplateProvider setUser(UserModel user)
setUser
in interface EmailTemplateProvider
public EmailTemplateProvider setAttribute(String name, Object value)
setAttribute
in interface EmailTemplateProvider
public EmailTemplateProvider setAuthenticationSession(AuthenticationSessionModel authenticationSession)
setAuthenticationSession
in interface EmailTemplateProvider
protected String getRealmName()
public void sendEvent(Event event) throws EmailException
sendEvent
in interface EmailTemplateProvider
EmailException
public void sendPasswordReset(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvider
sendPasswordReset
in interface EmailTemplateProvider
EmailException
public void sendSmtpTestEmail(Map<String,String> config, UserModel user) throws EmailException
EmailTemplateProvider
sendSmtpTestEmail
in interface EmailTemplateProvider
config
- SMTP server configurationuser
- SMTP recipientEmailException
public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvider
sendConfirmIdentityBrokerLink
in interface EmailTemplateProvider
EmailException
public void sendExecuteActions(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvider
sendExecuteActions
in interface EmailTemplateProvider
EmailException
public void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException
sendVerifyEmail
in interface EmailTemplateProvider
EmailException
protected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String,Object> attributes) throws EmailException
link
- to addexpirationInMinutes
- to addattributes
- to add link info intoEmailException
public void send(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException
EmailTemplateProvider
send
in interface EmailTemplateProvider
subjectFormatKey
- message property that will be used to format email subjectbodyTemplate
- freemarker template filebodyAttributes
- attributes used to fill templateEmailException
protected FreeMarkerEmailTemplateProvider.EmailTemplate processTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes) throws EmailException
EmailException
protected Theme getTheme() throws IOException
IOException
public void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException
EmailTemplateProvider
send
in interface EmailTemplateProvider
subjectFormatKey
- message property that will be used to format email subjectsubjectAttributes
- attributes used to fill subject format messagebodyTemplate
- freemarker template filebodyAttributes
- attributes used to fill templateEmailException
protected void send(String subject, String textBody, String htmlBody) throws EmailException
EmailException
protected void send(Map<String,String> config, String subject, String textBody, String htmlBody) throws EmailException
EmailException
Copyright © 2020 JBoss by Red Hat. All rights reserved.