Package org.keycloak.email.freemarker
Class FreeMarkerEmailTemplateProvider
- java.lang.Object
- 
- org.keycloak.email.freemarker.FreeMarkerEmailTemplateProvider
 
- 
- All Implemented Interfaces:
- EmailTemplateProvider,- Provider
 
 public class FreeMarkerEmailTemplateProvider extends Object implements EmailTemplateProvider - Author:
- Stian Thorgersen
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classFreeMarkerEmailTemplateProvider.EmailTemplate
 - 
Field SummaryFields Modifier and Type Field Description protected Map<String,Object>attributesprotected AuthenticationSessionModelauthenticationSessionauthenticationSession 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 FreeMarkerProviderfreeMarkerprotected RealmModelrealmprotected KeycloakSessionsessionprotected UserModeluser- 
Fields inherited from interface org.keycloak.email.EmailTemplateProviderIDENTITY_PROVIDER_BROKER_CONTEXT
 
- 
 - 
Constructor SummaryConstructors Constructor Description FreeMarkerEmailTemplateProvider(KeycloakSession session)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String,Object> attributes)Add link info into template attributes.voidclose()protected StringgetRealmName()protected ThemegetTheme()protected FreeMarkerEmailTemplateProvider.EmailTemplateprocessTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes)protected voidsend(String subject, String textBody, String htmlBody, String address)voidsend(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes)Send formatted emailvoidsend(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes)Send formatted emailprotected voidsend(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes, String address)protected voidsend(Map<String,String> config, String subject, String textBody, String htmlBody)protected voidsend(Map<String,String> config, String subject, String textBody, String htmlBody, String address)voidsendConfirmIdentityBrokerLink(String link, long expirationInMinutes)Send to confirm that user wants to link his account with identity broker linkvoidsendEmailUpdateConfirmation(String link, long expirationInMinutes, String newEmail)voidsendEvent(Event event)voidsendExecuteActions(String link, long expirationInMinutes)Change password email requested by adminvoidsendPasswordReset(String link, long expirationInMinutes)Reset password sent from forgot password link on loginvoidsendSmtpTestEmail(Map<String,String> config, UserModel user)Test SMTP connection with current logged in uservoidsendVerifyEmail(String link, long expirationInMinutes)EmailTemplateProvidersetAttribute(String name, Object value)EmailTemplateProvidersetAuthenticationSession(AuthenticationSessionModel authenticationSession)EmailTemplateProvidersetRealm(RealmModel realm)EmailTemplateProvidersetUser(UserModel user)protected StringtoCamelCase(EventType event)
 
- 
- 
- 
Field Detail- 
sessionprotected KeycloakSession session 
 - 
authenticationSessionprotected 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.)!
 - 
freeMarkerprotected FreeMarkerProvider freeMarker 
 - 
realmprotected RealmModel realm 
 - 
userprotected UserModel user 
 
- 
 - 
Constructor Detail- 
FreeMarkerEmailTemplateProviderpublic FreeMarkerEmailTemplateProvider(KeycloakSession session) 
 
- 
 - 
Method Detail- 
setRealmpublic EmailTemplateProvider setRealm(RealmModel realm) - Specified by:
- setRealmin interface- EmailTemplateProvider
 
 - 
setUserpublic EmailTemplateProvider setUser(UserModel user) - Specified by:
- setUserin interface- EmailTemplateProvider
 
 - 
setAttributepublic EmailTemplateProvider setAttribute(String name, Object value) - Specified by:
- setAttributein interface- EmailTemplateProvider
 
 - 
setAuthenticationSessionpublic EmailTemplateProvider setAuthenticationSession(AuthenticationSessionModel authenticationSession) - Specified by:
- setAuthenticationSessionin interface- EmailTemplateProvider
 
 - 
getRealmNameprotected String getRealmName() 
 - 
sendEventpublic void sendEvent(Event event) throws EmailException - Specified by:
- sendEventin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
sendPasswordResetpublic void sendPasswordReset(String link, long expirationInMinutes) throws EmailException Description copied from interface:EmailTemplateProviderReset password sent from forgot password link on login- Specified by:
- sendPasswordResetin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
sendSmtpTestEmailpublic void sendSmtpTestEmail(Map<String,String> config, UserModel user) throws EmailException Description copied from interface:EmailTemplateProviderTest SMTP connection with current logged in user- Specified by:
- sendSmtpTestEmailin interface- EmailTemplateProvider
- Parameters:
- config- SMTP server configuration
- user- SMTP recipient
- Throws:
- EmailException
 
 - 
sendConfirmIdentityBrokerLinkpublic void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException Description copied from interface:EmailTemplateProviderSend to confirm that user wants to link his account with identity broker link- Specified by:
- sendConfirmIdentityBrokerLinkin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
sendExecuteActionspublic void sendExecuteActions(String link, long expirationInMinutes) throws EmailException Description copied from interface:EmailTemplateProviderChange password email requested by admin- Specified by:
- sendExecuteActionsin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
sendVerifyEmailpublic void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException - Specified by:
- sendVerifyEmailin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
sendEmailUpdateConfirmationpublic void sendEmailUpdateConfirmation(String link, long expirationInMinutes, String newEmail) throws EmailException - Specified by:
- sendEmailUpdateConfirmationin interface- EmailTemplateProvider
- Throws:
- EmailException
 
 - 
addLinkInfoIntoAttributesprotected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String,Object> attributes) throws EmailException Add link info into template attributes.- Parameters:
- link- to add
- expirationInMinutes- to add
- attributes- to add link info into
- Throws:
- EmailException
 
 - 
sendpublic void send(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException Description copied from interface:EmailTemplateProviderSend formatted email- Specified by:
- sendin interface- EmailTemplateProvider
- Parameters:
- subjectFormatKey- message property that will be used to format email subject
- bodyTemplate- freemarker template file
- bodyAttributes- attributes used to fill template
- Throws:
- EmailException
 
 - 
processTemplateprotected FreeMarkerEmailTemplateProvider.EmailTemplate processTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes) throws EmailException - Throws:
- EmailException
 
 - 
getThemeprotected Theme getTheme() throws IOException - Throws:
- IOException
 
 - 
sendpublic void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes) throws EmailException Description copied from interface:EmailTemplateProviderSend formatted email- Specified by:
- sendin interface- EmailTemplateProvider
- Parameters:
- subjectFormatKey- message property that will be used to format email subject
- subjectAttributes- attributes used to fill subject format message
- bodyTemplate- freemarker template file
- bodyAttributes- attributes used to fill template
- Throws:
- EmailException
 
 - 
sendprotected void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes, String address) throws EmailException - Throws:
- EmailException
 
 - 
sendprotected void send(String subject, String textBody, String htmlBody, String address) throws EmailException - Throws:
- EmailException
 
 - 
sendprotected void send(Map<String,String> config, String subject, String textBody, String htmlBody) throws EmailException - Throws:
- EmailException
 
 - 
sendprotected void send(Map<String,String> config, String subject, String textBody, String htmlBody, String address) throws EmailException - Throws:
- EmailException
 
 
- 
 
-