Package org.keycloak.email.freemarker
Class FreeMarkerEmailTemplateProvider
- java.lang.Object
-
- org.keycloak.email.freemarker.FreeMarkerEmailTemplateProvider
-
- All Implemented Interfaces:
org.keycloak.email.EmailTemplateProvider,org.keycloak.provider.Provider
public class FreeMarkerEmailTemplateProvider extends Object implements org.keycloak.email.EmailTemplateProvider
- Author:
- Stian Thorgersen
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classFreeMarkerEmailTemplateProvider.EmailTemplate
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>attributesprotected org.keycloak.sessions.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 FreeMarkerUtilfreeMarkerprotected org.keycloak.models.RealmModelrealmprotected org.keycloak.models.KeycloakSessionsessionprotected org.keycloak.models.UserModeluser
-
Constructor Summary
Constructors Constructor Description FreeMarkerEmailTemplateProvider(org.keycloak.models.KeycloakSession session, FreeMarkerUtil freeMarker)
-
Method Summary
All 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 org.keycloak.theme.ThemegetTheme()protected FreeMarkerEmailTemplateProvider.EmailTemplateprocessTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes)protected voidsend(String subject, String textBody, String htmlBody)voidsend(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes)voidsend(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes)protected voidsend(Map<String,String> config, String subject, String textBody, String htmlBody)voidsendConfirmIdentityBrokerLink(String link, long expirationInMinutes)voidsendEvent(org.keycloak.events.Event event)voidsendExecuteActions(String link, long expirationInMinutes)voidsendPasswordReset(String link, long expirationInMinutes)voidsendSmtpTestEmail(Map<String,String> config, org.keycloak.models.UserModel user)voidsendVerifyEmail(String link, long expirationInMinutes)org.keycloak.email.EmailTemplateProvidersetAttribute(String name, Object value)org.keycloak.email.EmailTemplateProvidersetAuthenticationSession(org.keycloak.sessions.AuthenticationSessionModel authenticationSession)org.keycloak.email.EmailTemplateProvidersetRealm(org.keycloak.models.RealmModel realm)org.keycloak.email.EmailTemplateProvidersetUser(org.keycloak.models.UserModel user)protected StringtoCamelCase(org.keycloak.events.EventType event)
-
-
-
Field Detail
-
session
protected org.keycloak.models.KeycloakSession session
-
authenticationSession
protected org.keycloak.sessions.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.)!
-
freeMarker
protected FreeMarkerUtil freeMarker
-
realm
protected org.keycloak.models.RealmModel realm
-
user
protected org.keycloak.models.UserModel user
-
-
Constructor Detail
-
FreeMarkerEmailTemplateProvider
public FreeMarkerEmailTemplateProvider(org.keycloak.models.KeycloakSession session, FreeMarkerUtil freeMarker)
-
-
Method Detail
-
setRealm
public org.keycloak.email.EmailTemplateProvider setRealm(org.keycloak.models.RealmModel realm)
- Specified by:
setRealmin interfaceorg.keycloak.email.EmailTemplateProvider
-
setUser
public org.keycloak.email.EmailTemplateProvider setUser(org.keycloak.models.UserModel user)
- Specified by:
setUserin interfaceorg.keycloak.email.EmailTemplateProvider
-
setAttribute
public org.keycloak.email.EmailTemplateProvider setAttribute(String name, Object value)
- Specified by:
setAttributein interfaceorg.keycloak.email.EmailTemplateProvider
-
setAuthenticationSession
public org.keycloak.email.EmailTemplateProvider setAuthenticationSession(org.keycloak.sessions.AuthenticationSessionModel authenticationSession)
- Specified by:
setAuthenticationSessionin interfaceorg.keycloak.email.EmailTemplateProvider
-
getRealmName
protected String getRealmName()
-
sendEvent
public void sendEvent(org.keycloak.events.Event event) throws org.keycloak.email.EmailException- Specified by:
sendEventin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
sendPasswordReset
public void sendPasswordReset(String link, long expirationInMinutes) throws org.keycloak.email.EmailException
- Specified by:
sendPasswordResetin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
sendSmtpTestEmail
public void sendSmtpTestEmail(Map<String,String> config, org.keycloak.models.UserModel user) throws org.keycloak.email.EmailException
- Specified by:
sendSmtpTestEmailin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
sendConfirmIdentityBrokerLink
public void sendConfirmIdentityBrokerLink(String link, long expirationInMinutes) throws org.keycloak.email.EmailException
- Specified by:
sendConfirmIdentityBrokerLinkin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
sendExecuteActions
public void sendExecuteActions(String link, long expirationInMinutes) throws org.keycloak.email.EmailException
- Specified by:
sendExecuteActionsin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
sendVerifyEmail
public void sendVerifyEmail(String link, long expirationInMinutes) throws org.keycloak.email.EmailException
- Specified by:
sendVerifyEmailin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
addLinkInfoIntoAttributes
protected void addLinkInfoIntoAttributes(String link, long expirationInMinutes, Map<String,Object> attributes) throws org.keycloak.email.EmailException
Add link info into template attributes.- Parameters:
link- to addexpirationInMinutes- to addattributes- to add link info into- Throws:
org.keycloak.email.EmailException
-
send
public void send(String subjectFormatKey, String bodyTemplate, Map<String,Object> bodyAttributes) throws org.keycloak.email.EmailException
- Specified by:
sendin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
processTemplate
protected FreeMarkerEmailTemplateProvider.EmailTemplate processTemplate(String subjectKey, List<Object> subjectAttributes, String template, Map<String,Object> attributes) throws org.keycloak.email.EmailException
- Throws:
org.keycloak.email.EmailException
-
getTheme
protected org.keycloak.theme.Theme getTheme() throws IOException- Throws:
IOException
-
send
public void send(String subjectFormatKey, List<Object> subjectAttributes, String bodyTemplate, Map<String,Object> bodyAttributes) throws org.keycloak.email.EmailException
- Specified by:
sendin interfaceorg.keycloak.email.EmailTemplateProvider- Throws:
org.keycloak.email.EmailException
-
send
protected void send(String subject, String textBody, String htmlBody) throws org.keycloak.email.EmailException
- Throws:
org.keycloak.email.EmailException
-
send
protected void send(Map<String,String> config, String subject, String textBody, String htmlBody) throws org.keycloak.email.EmailException
- Throws:
org.keycloak.email.EmailException
-
close
public void close()
- Specified by:
closein interfaceorg.keycloak.provider.Provider
-
toCamelCase
protected String toCamelCase(org.keycloak.events.EventType event)
-
-