public class FreeMarkerEmailTemplateProvider extends Object implements EmailTemplateProvider
| Modifier and Type | Class and Description |
|---|---|
protected static 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 EmailTemplateProviderpublic EmailTemplateProvider setUser(UserModel user)
setUser in interface EmailTemplateProviderpublic EmailTemplateProvider setAttribute(String name, Object value)
setAttribute in interface EmailTemplateProviderpublic EmailTemplateProvider setAuthenticationSession(AuthenticationSessionModel authenticationSession)
setAuthenticationSession in interface EmailTemplateProviderprotected String getRealmName()
public void sendEvent(Event event) throws EmailException
sendEvent in interface EmailTemplateProviderEmailExceptionpublic void sendPasswordReset(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvidersendPasswordReset in interface EmailTemplateProviderEmailExceptionpublic void sendSmtpTestEmail(Map<String,String> config, UserModel user) throws EmailException
EmailTemplateProvidersendSmtpTestEmail in interface EmailTemplateProviderconfig - SMTP server configurationuser - SMTP recipientEmailExceptionpublic void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvidersendConfirmIdentityBrokerLink in interface EmailTemplateProviderEmailExceptionpublic void sendExecuteActions(String link, long expirationInMinutes) throws EmailException
EmailTemplateProvidersendExecuteActions in interface EmailTemplateProviderEmailExceptionpublic void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException
sendVerifyEmail in interface EmailTemplateProviderEmailExceptionprotected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String,Object> attributes) throws EmailException
link - to addexpirationInMinutes - to addattributes - to add link info intoEmailExceptionpublic void send(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException
EmailTemplateProvidersend in interface EmailTemplateProvidersubjectFormatKey - message property that will be used to format email subjectbodyTemplate - freemarker template filebodyAttributes - attributes used to fill templateEmailExceptionprotected FreeMarkerEmailTemplateProvider.EmailTemplate processTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes) throws EmailException
EmailExceptionprotected Theme getTheme() throws IOException
IOExceptionpublic void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException
EmailTemplateProvidersend in interface EmailTemplateProvidersubjectFormatKey - message property that will be used to format email subjectsubjectAttributes - attributes used to fill subject format messagebodyTemplate - freemarker template filebodyAttributes - attributes used to fill templateEmailExceptionprotected void send(String subject, String textBody, String htmlBody) throws EmailException
EmailExceptionprotected void send(Map<String,String> config, String subject, String textBody, String htmlBody) throws EmailException
EmailExceptionCopyright © 2021 JBoss by Red Hat. All rights reserved.