Package org.keycloak.email.freemarker
Class FreeMarkerEmailTemplateProvider
java.lang.Object
org.keycloak.email.freemarker.FreeMarkerEmailTemplateProvider
- All Implemented Interfaces:
EmailTemplateProvider
,Provider
- Author:
- Stian Thorgersen
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected AuthenticationSessionModel
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 FreeMarkerProvider
protected RealmModel
protected KeycloakSession
protected UserModel
Fields inherited from interface org.keycloak.email.EmailTemplateProvider
IDENTITY_PROVIDER_BROKER_CONTEXT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addLinkInfoIntoAttributes
(String link, long expirationInMinutes, Map<String, Object> attributes) Add link info into template attributes.void
close()
protected String
protected Theme
getTheme()
processTemplate
(String subjectKey, List<Object> subjectAttributes, String template, Map<String, Object> attributes) protected void
void
Send formatted emailvoid
send
(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String, Object> bodyAttributes) Send formatted emailprotected void
send
(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String, Object> bodyAttributes, String address) protected void
protected void
void
sendConfirmIdentityBrokerLink
(String link, long expirationInMinutes) Send to confirm that user wants to link his account with identity broker linkvoid
sendEmailUpdateConfirmation
(String link, long expirationInMinutes, String newEmail) void
void
sendExecuteActions
(String link, long expirationInMinutes) Change password email requested by adminvoid
sendOrgInviteEmail
(OrganizationModel organization, String link, long expirationInMinutes) void
sendPasswordReset
(String link, long expirationInMinutes) Reset password sent from forgot password link on loginvoid
sendSmtpTestEmail
(Map<String, String> config, UserModel user) Test SMTP connection with current logged in uservoid
sendVerifyEmail
(String link, long expirationInMinutes) setAttribute
(String name, Object value) setAuthenticationSession
(AuthenticationSessionModel authenticationSession) setRealm
(RealmModel realm) protected String
toCamelCase
(EventType event)
-
Field Details
-
session
-
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.)! -
freeMarker
-
realm
-
user
-
attributes
-
-
Constructor Details
-
FreeMarkerEmailTemplateProvider
-
-
Method Details
-
setRealm
- Specified by:
setRealm
in interfaceEmailTemplateProvider
-
setUser
- Specified by:
setUser
in interfaceEmailTemplateProvider
-
setAttribute
- Specified by:
setAttribute
in interfaceEmailTemplateProvider
-
setAuthenticationSession
public EmailTemplateProvider setAuthenticationSession(AuthenticationSessionModel authenticationSession) - Specified by:
setAuthenticationSession
in interfaceEmailTemplateProvider
-
getRealmName
-
sendEvent
- Specified by:
sendEvent
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendPasswordReset
Description copied from interface:EmailTemplateProvider
Reset password sent from forgot password link on login- Specified by:
sendPasswordReset
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendSmtpTestEmail
Description copied from interface:EmailTemplateProvider
Test SMTP connection with current logged in user- Specified by:
sendSmtpTestEmail
in interfaceEmailTemplateProvider
- Parameters:
config
- SMTP server configurationuser
- SMTP recipient- Throws:
EmailException
-
sendConfirmIdentityBrokerLink
public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws EmailException Description copied from interface:EmailTemplateProvider
Send to confirm that user wants to link his account with identity broker link- Specified by:
sendConfirmIdentityBrokerLink
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendExecuteActions
Description copied from interface:EmailTemplateProvider
Change password email requested by admin- Specified by:
sendExecuteActions
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendVerifyEmail
- Specified by:
sendVerifyEmail
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendOrgInviteEmail
public void sendOrgInviteEmail(OrganizationModel organization, String link, long expirationInMinutes) throws EmailException - Specified by:
sendOrgInviteEmail
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
sendEmailUpdateConfirmation
public void sendEmailUpdateConfirmation(String link, long expirationInMinutes, String newEmail) throws EmailException - Specified by:
sendEmailUpdateConfirmation
in interfaceEmailTemplateProvider
- Throws:
EmailException
-
addLinkInfoIntoAttributes
protected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String, Object> attributes) throws EmailExceptionAdd link info into template attributes.- Parameters:
link
- to addexpirationInMinutes
- to addattributes
- to add link info into- Throws:
EmailException
-
send
public void send(String subjectFormatKey, String bodyTemplate, Map<String, Object> bodyAttributes) throws EmailExceptionDescription copied from interface:EmailTemplateProvider
Send formatted email- Specified by:
send
in interfaceEmailTemplateProvider
- Parameters:
subjectFormatKey
- message property that will be used to format email subjectbodyTemplate
- freemarker template filebodyAttributes
- attributes used to fill template- Throws:
EmailException
-
processTemplate
protected FreeMarkerEmailTemplateProvider.EmailTemplate processTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String, Object> attributes) throws EmailException- Throws:
EmailException
-
getTheme
- Throws:
IOException
-
send
public void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String, Object> bodyAttributes) throws EmailExceptionDescription copied from interface:EmailTemplateProvider
Send formatted email- Specified by:
send
in interfaceEmailTemplateProvider
- Parameters:
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 template- Throws:
EmailException
-
send
protected void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String, Object> bodyAttributes, String address) throws EmailException- Throws:
EmailException
-
send
protected void send(String subject, String textBody, String htmlBody, String address) throws EmailException - Throws:
EmailException
-
send
protected void send(Map<String, String> config, String subject, String textBody, String htmlBody) throws EmailException- Throws:
EmailException
-
send
protected void send(Map<String, String> config, String subject, String textBody, String htmlBody, String address) throws EmailException- Throws:
EmailException
-
close
public void close() -
toCamelCase
-