diff --git a/audit/mongo/src/main/java/org/keycloak/audit/mongo/MongoAuditProviderFactory.java b/audit/mongo/src/main/java/org/keycloak/audit/mongo/MongoAuditProviderFactory.java index 4ffcda1b16..09cb6fde5c 100644 --- a/audit/mongo/src/main/java/org/keycloak/audit/mongo/MongoAuditProviderFactory.java +++ b/audit/mongo/src/main/java/org/keycloak/audit/mongo/MongoAuditProviderFactory.java @@ -18,10 +18,6 @@ import java.util.Collections; */ public class MongoAuditProviderFactory implements AuditProviderFactory { - private static final String MONGO_HOST = "keycloak.audit.mongo.host"; - private static final String MONGO_PORT = "keycloak.audit.mongo.port"; - private static final String MONGO_DB_NAME = "keycloak.audit.mongo.db"; - public static final String ID = "mongo"; private MongoClient client; private DB db; diff --git a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java index 9c43eb6c8f..e60727c743 100755 --- a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java @@ -57,6 +57,7 @@ public class RealmRepresentation { protected String loginTheme; protected String accountTheme; protected String adminTheme; + protected String emailTheme; protected boolean auditEnabled; protected long auditExpiration; protected List auditListeners; @@ -377,6 +378,14 @@ public class RealmRepresentation { this.adminTheme = adminTheme; } + public String getEmailTheme() { + return emailTheme; + } + + public void setEmailTheme(String emailTheme) { + this.emailTheme = emailTheme; + } + public Integer getNotBefore() { return notBefore; } diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-detail.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-detail.html index d2e60f52be..a2b916124f 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-detail.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/realm-detail.html @@ -111,6 +111,18 @@ +
+ +
+
+ +
+
+
diff --git a/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailProvider.java b/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailProvider.java index 9590a9cd41..e4e8c52b57 100644 --- a/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailProvider.java +++ b/forms/email-freemarker/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailProvider.java @@ -68,7 +68,7 @@ public class FreeMarkerEmailProvider implements EmailProvider { private void send(String subjectKey, String template, Map attributes) throws EmailException { try { ExtendingThemeManager themeManager = new ExtendingThemeManager(session); - Theme theme = themeManager.createTheme(realm.getAccountTheme(), Theme.Type.EMAIL); + Theme theme = themeManager.createTheme(realm.getEmailTheme(), Theme.Type.EMAIL); String subject = theme.getMessages().getProperty(subjectKey); String body = FreeMarkerUtil.processTemplate(attributes, template, theme); diff --git a/model/api/src/main/java/org/keycloak/models/RealmModel.java b/model/api/src/main/java/org/keycloak/models/RealmModel.java index 68a89eae5e..8f348e0c3e 100755 --- a/model/api/src/main/java/org/keycloak/models/RealmModel.java +++ b/model/api/src/main/java/org/keycloak/models/RealmModel.java @@ -222,6 +222,10 @@ public interface RealmModel extends RoleContainerModel, RoleMapperModel, ScopeMa void setAdminTheme(String name); + String getEmailTheme(); + + void setEmailTheme(String name); + boolean hasScope(ClientModel client, RoleModel role); /** diff --git a/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java b/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java index d19ca0988b..81041e0698 100755 --- a/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java +++ b/model/api/src/main/java/org/keycloak/models/entities/RealmEntity.java @@ -43,6 +43,7 @@ public class RealmEntity extends AbstractIdentifiableEntity { private String loginTheme; private String accountTheme; private String adminTheme; + private String emailTheme; // We are using names of defaultRoles (not ids) private List defaultRoles = new ArrayList(); @@ -284,6 +285,14 @@ public class RealmEntity extends AbstractIdentifiableEntity { this.adminTheme = adminTheme; } + public String getEmailTheme() { + return emailTheme; + } + + public void setEmailTheme(String emailTheme) { + this.emailTheme = emailTheme; + } + public List getDefaultRoles() { return defaultRoles; } diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java index b3eb12f392..da4647170d 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RealmAdapter.java @@ -1351,6 +1351,17 @@ public class RealmAdapter implements RealmModel { em.flush(); } + @Override + public String getEmailTheme() { + return realm.getEmailTheme(); + } + + @Override + public void setEmailTheme(String name) { + realm.setEmailTheme(name); + em.flush(); + } + @Override public boolean isAuditEnabled() { return realm.isAuditEnabled(); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java index c5bf40c6a7..e0aff1b5af 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmEntity.java @@ -75,6 +75,7 @@ public class RealmEntity { protected String loginTheme; protected String accountTheme; protected String adminTheme; + protected String emailTheme; @OneToMany(cascade ={CascadeType.REMOVE}, orphanRemoval = true) @JoinTable(name="User_RequiredCreds") @@ -360,6 +361,14 @@ public class RealmEntity { this.adminTheme = adminTheme; } + public String getEmailTheme() { + return emailTheme; + } + + public void setEmailTheme(String emailTheme) { + this.emailTheme = emailTheme; + } + public int getNotBefore() { return notBefore; } diff --git a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java index f7e82ec89a..97ef792a2d 100755 --- a/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java +++ b/model/mongo/src/main/java/org/keycloak/models/mongo/keycloak/adapters/RealmAdapter.java @@ -420,6 +420,17 @@ public class RealmAdapter extends AbstractMongoAdapter impleme updateRealm(); } + @Override + public String getEmailTheme() { + return realm.getEmailTheme(); + } + + @Override + public void setEmailTheme(String name) { + realm.setEmailTheme(name); + updateRealm(); + } + @Override public UserAdapter getUser(String name) { DBObject query = new QueryBuilder() diff --git a/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java b/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java index 1f4665ca61..1f4b8d4d29 100755 --- a/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java +++ b/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java @@ -103,6 +103,7 @@ public class ModelToRepresentation { rep.setAccountTheme(realm.getAccountTheme()); rep.setLoginTheme(realm.getLoginTheme()); rep.setAdminTheme(realm.getAdminTheme()); + rep.setEmailTheme(realm.getEmailTheme()); if (realm.getPasswordPolicy() != null) { rep.setPasswordPolicy(realm.getPasswordPolicy().toString()); } diff --git a/services/src/main/java/org/keycloak/services/managers/RealmManager.java b/services/src/main/java/org/keycloak/services/managers/RealmManager.java index 15648c8b58..640eb39ae2 100755 --- a/services/src/main/java/org/keycloak/services/managers/RealmManager.java +++ b/services/src/main/java/org/keycloak/services/managers/RealmManager.java @@ -194,6 +194,7 @@ public class RealmManager { if (rep.getLoginTheme() != null) realm.setLoginTheme(rep.getLoginTheme()); if (rep.getAccountTheme() != null) realm.setAccountTheme(rep.getAccountTheme()); if (rep.getAdminTheme() != null) realm.setAdminTheme(rep.getAdminTheme()); + if (rep.getEmailTheme() != null) realm.setEmailTheme(rep.getEmailTheme()); if (rep.getPasswordPolicy() != null) realm.setPasswordPolicy(new PasswordPolicy(rep.getPasswordPolicy())); @@ -344,7 +345,8 @@ public class RealmManager { } if (rep.getLoginTheme() != null) newRealm.setLoginTheme(rep.getLoginTheme()); if (rep.getAccountTheme() != null) newRealm.setAccountTheme(rep.getAccountTheme()); - if (rep.getAdminTheme() != null) newRealm.setAdminTheme(rep.getAccountTheme()); + if (rep.getAdminTheme() != null) newRealm.setAdminTheme(rep.getAdminTheme()); + if (rep.getEmailTheme() != null) newRealm.setEmailTheme(rep.getEmailTheme()); Map userMap = new HashMap(); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java index b617266eb1..028f198a31 100644 --- a/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/ServerInfoAdminResource.java @@ -37,11 +37,11 @@ public class ServerInfoAdminResource { } private void setThemes(ServerInfoRepresentation info) { - Iterable providers = ProviderLoader.load(ThemeProvider.class); + Set themeProviders = providers.getAllProviders(ThemeProvider.class); info.themes = new HashMap>(); for (Theme.Type type : Theme.Type.values()) { List themes = new LinkedList(); - for (ThemeProvider p : providers) { + for (ThemeProvider p : themeProviders) { themes.addAll(p.nameSet(type)); } Collections.sort(themes);