Merge pull request #2056 from stianst/KEYCLOAK-2344

KEYCLOAK-2344
This commit is contained in:
Stian Thorgersen 2016-01-19 13:35:42 +01:00
commit 65521864d4

View file

@ -55,6 +55,14 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
return this; return this;
} }
private String getRealmName() {
if (realm.getDisplayName() != null) {
return realm.getDisplayName();
} else {
return ObjectUtil.capitalize(realm.getName());
}
}
@Override @Override
public void sendEvent(Event event) throws EmailException { public void sendEvent(Event event) throws EmailException {
Map<String, Object> attributes = new HashMap<String, Object>(); Map<String, Object> attributes = new HashMap<String, Object>();
@ -71,8 +79,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
attributes.put("link", link); attributes.put("link", link);
attributes.put("linkExpiration", expirationInMinutes); attributes.put("linkExpiration", expirationInMinutes);
String realmName = ObjectUtil.capitalize(realm.getName()); attributes.put("realmName", getRealmName());
attributes.put("realmName", realmName);
send("passwordResetSubject", "password-reset.ftl", attributes); send("passwordResetSubject", "password-reset.ftl", attributes);
} }
@ -84,8 +91,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
attributes.put("link", link); attributes.put("link", link);
attributes.put("linkExpiration", expirationInMinutes); attributes.put("linkExpiration", expirationInMinutes);
String realmName = ObjectUtil.capitalize(realm.getName()); attributes.put("realmName", getRealmName());
attributes.put("realmName", realmName);
BrokeredIdentityContext brokerContext = (BrokeredIdentityContext) this.attributes.get(IDENTITY_PROVIDER_BROKER_CONTEXT); BrokeredIdentityContext brokerContext = (BrokeredIdentityContext) this.attributes.get(IDENTITY_PROVIDER_BROKER_CONTEXT);
String idpAlias = brokerContext.getIdpConfig().getAlias(); String idpAlias = brokerContext.getIdpConfig().getAlias();
@ -105,8 +111,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
attributes.put("link", link); attributes.put("link", link);
attributes.put("linkExpiration", expirationInMinutes); attributes.put("linkExpiration", expirationInMinutes);
String realmName = ObjectUtil.capitalize(realm.getName()); attributes.put("realmName", getRealmName());
attributes.put("realmName", realmName);
send("executeActionsSubject", "executeActions.ftl", attributes); send("executeActionsSubject", "executeActions.ftl", attributes);
@ -119,8 +124,7 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
attributes.put("link", link); attributes.put("link", link);
attributes.put("linkExpiration", expirationInMinutes); attributes.put("linkExpiration", expirationInMinutes);
String realmName = ObjectUtil.capitalize(realm.getName()); attributes.put("realmName", getRealmName());
attributes.put("realmName", realmName);
send("emailVerificationSubject", "email-verification.ftl", attributes); send("emailVerificationSubject", "email-verification.ftl", attributes);
} }