From e50709fc2d22c28519dea98bd450b64a3d1b5199 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Tue, 19 Jan 2016 13:01:30 +0100 Subject: [PATCH] KEYCLOAK-2344 Realm Display Name is not used in verification e-mail --- .../FreeMarkerEmailTemplateProvider.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java b/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java index 4ce817021e..0a4785188b 100755 --- a/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java +++ b/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java @@ -55,6 +55,14 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider { return this; } + private String getRealmName() { + if (realm.getDisplayName() != null) { + return realm.getDisplayName(); + } else { + return ObjectUtil.capitalize(realm.getName()); + } + } + @Override public void sendEvent(Event event) throws EmailException { Map attributes = new HashMap(); @@ -71,8 +79,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider { attributes.put("link", link); attributes.put("linkExpiration", expirationInMinutes); - String realmName = ObjectUtil.capitalize(realm.getName()); - attributes.put("realmName", realmName); + attributes.put("realmName", getRealmName()); send("passwordResetSubject", "password-reset.ftl", attributes); } @@ -84,8 +91,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider { attributes.put("link", link); attributes.put("linkExpiration", expirationInMinutes); - String realmName = ObjectUtil.capitalize(realm.getName()); - attributes.put("realmName", realmName); + attributes.put("realmName", getRealmName()); BrokeredIdentityContext brokerContext = (BrokeredIdentityContext) this.attributes.get(IDENTITY_PROVIDER_BROKER_CONTEXT); String idpAlias = brokerContext.getIdpConfig().getAlias(); @@ -105,8 +111,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider { attributes.put("link", link); attributes.put("linkExpiration", expirationInMinutes); - String realmName = ObjectUtil.capitalize(realm.getName()); - attributes.put("realmName", realmName); + attributes.put("realmName", getRealmName()); send("executeActionsSubject", "executeActions.ftl", attributes); @@ -119,8 +124,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider { attributes.put("link", link); attributes.put("linkExpiration", expirationInMinutes); - String realmName = ObjectUtil.capitalize(realm.getName()); - attributes.put("realmName", realmName); + attributes.put("realmName", getRealmName()); send("emailVerificationSubject", "email-verification.ftl", attributes); }