diff --git a/jans-keycloak-link/server/pom.xml b/jans-keycloak-link/server/pom.xml
index 75a754de219..034ca6d63f9 100644
--- a/jans-keycloak-link/server/pom.xml
+++ b/jans-keycloak-link/server/pom.xml
@@ -33,16 +33,6 @@
io.jans
jans-core-service
-
-
- io.jans
- jans-core-document-store
-
-
- io.jans
- jans-core-message
-
-
diff --git a/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/server/service/ConfigurationService.java b/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/server/service/ConfigurationService.java
new file mode 100644
index 00000000000..4f8a766e64a
--- /dev/null
+++ b/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/server/service/ConfigurationService.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright [2024] [Janssen Project]
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.jans.keycloak.link.server.service;
+
+import io.jans.config.GluuConfiguration;
+import io.jans.keycloak.link.model.config.StaticConfiguration;
+import io.jans.model.SmtpConfiguration;
+import io.jans.orm.PersistenceEntryManager;
+import io.jans.service.EncryptionService;
+import io.jans.util.StringHelper;
+import io.jans.util.security.StringEncrypter.EncryptionException;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.slf4j.Logger;
+
+/**
+ *
+ * @author Yuriy Movchan Date: 12/12/2023
+ */
+@ApplicationScoped
+public class ConfigurationService {
+
+ @Inject
+ private Logger log;
+
+ @Inject
+ private PersistenceEntryManager persistenceEntryManager;
+
+ @Inject
+ private StaticConfiguration staticConfiguration;
+
+ @Inject
+ private EncryptionService encryptionService;
+
+ public GluuConfiguration getConfiguration() {
+ String configurationDn = staticConfiguration.getBaseDn().getConfiguration();
+ if (StringHelper.isEmpty(configurationDn)) {
+ return null;
+ }
+
+ return persistenceEntryManager.find(GluuConfiguration.class, configurationDn);
+ }
+
+ /**
+ * Build DN string for configuration
+ *
+ * @param inum Inum
+ * @return DN string for specified configuration or DN for configurations branch if inum is null
+ * @throws Exception
+ */
+ public String getDnForConfiguration(String inum) {
+ String baseDn = staticConfiguration.getBaseDn().getConfiguration();
+ if (StringHelper.isEmpty(inum)) {
+ return baseDn;
+ }
+
+ return String.format("inum=%s,%s", inum, baseDn);
+ }
+
+ public void decryptSmtpPasswords(SmtpConfiguration smtpConfiguration) {
+ if (smtpConfiguration == null) {
+ return;
+ }
+ String password = smtpConfiguration.getSmtpAuthenticationAccountPassword();
+ if (StringHelper.isNotEmpty(password)) {
+ try {
+ smtpConfiguration.setSmtpAuthenticationAccountPasswordDecrypted(encryptionService.decrypt(password));
+ } catch (EncryptionException ex) {
+ log.error("Failed to decrypt SMTP user password", ex);
+ }
+ }
+ password = smtpConfiguration.getKeyStorePassword();
+ if (StringHelper.isNotEmpty(password)) {
+ try {
+ smtpConfiguration.setKeyStorePasswordDecrypted(encryptionService.decrypt(password));
+ } catch (EncryptionException ex) {
+ log.error("Failed to decrypt Kestore password", ex);
+ }
+ }
+ }
+
+}
+
diff --git a/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/service/config/ApplicationFactory.java b/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/service/config/ApplicationFactory.java
index 63e8978275d..4804abbd9ae 100644
--- a/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/service/config/ApplicationFactory.java
+++ b/jans-keycloak-link/server/src/main/java/io/jans/keycloak/link/service/config/ApplicationFactory.java
@@ -6,6 +6,14 @@
package io.jans.keycloak.link.service.config;
+import io.jans.config.GluuConfiguration;
+import io.jans.keycloak.link.server.service.ConfigurationService;
+import io.jans.service.document.store.conf.DocumentStoreConfiguration;
+import io.jans.service.document.store.conf.LocalDocumentStoreConfiguration;
+import io.jans.service.message.model.config.MessageConfiguration;
+import io.jans.service.message.model.config.MessageProviderType;
+import io.jans.service.message.model.config.NullMessageConfiguration;
+import jakarta.enterprise.inject.Produces;
import org.slf4j.Logger;
import io.jans.keycloak.link.model.config.AppConfiguration;
@@ -35,6 +43,9 @@ public class ApplicationFactory {
@Inject
private AppConfiguration appConfiguration;
+ @Inject
+ private ConfigurationService сonfigurationService;
+
public static final String PERSISTENCE_ENTRY_MANAGER_FACTORY_NAME = "persistenceEntryManagerFactory";
public static final String PERSISTENCE_ENTRY_MANAGER_NAME = "persistenceEntryManager";
@@ -57,4 +68,44 @@ public PersistenceEntryManagerFactory getPersistenceEntryManagerFactory(Class
return persistanceFactoryService.getPersistenceEntryManagerFactory(persistenceEntryManagerFactoryClass);
}
+ @Produces
+ @ApplicationScoped
+ public DocumentStoreConfiguration getDocumentStoreConfiguration() {
+ GluuConfiguration jansConf = сonfigurationService.getConfiguration();
+ DocumentStoreConfiguration documentStoreConfiguration = jansConf.getDocumentStoreConfiguration();
+ if ((documentStoreConfiguration == null) || (documentStoreConfiguration.getDocumentStoreType() == null)) {
+ log.error("Failed to read document store configuration from DB. Please check configuration jsDocStoreConf attribute " +
+ "that must contain document store configuration JSON represented by DocumentStoreConfiguration.class. Appliance DN: {0}", jansConf.getDn());
+ log.info("Creating fallback LOCAL document store configuration ... ");
+
+ documentStoreConfiguration = new DocumentStoreConfiguration();
+ documentStoreConfiguration.setLocalConfiguration(new LocalDocumentStoreConfiguration());
+
+ log.info("LOCAL document store configuration is created.");
+ }
+
+ log.info("Document store configuration: {0}" , documentStoreConfiguration);
+ return documentStoreConfiguration;
+ }
+
+ @Produces
+ @ApplicationScoped
+ public MessageConfiguration getMessageConfiguration() {
+ GluuConfiguration jansConf = сonfigurationService.getConfiguration();
+ MessageConfiguration messageConfiguration = jansConf.getMessageConfiguration();
+ if (messageConfiguration == null || messageConfiguration.getMessageProviderType() == null) {
+ log.error("Failed to read message configuration from DB. Please check configuration jsMessageConf attribute " +
+ "that must contain message configuration JSON represented by MessageConfiguration.class. Appliance DN: {0}" , jansConf.getDn());
+ log.info("Creating fallback Null message configuration ... ");
+
+ messageConfiguration = new MessageConfiguration();
+ messageConfiguration.setMessageProviderType(MessageProviderType.DISABLED);
+ messageConfiguration.setNullConfiguration(new NullMessageConfiguration());
+
+ log.info("NULL message configuration is created.");
+ }
+
+ log.info("Message configuration: {0}" , messageConfiguration);
+ return messageConfiguration;
+ }
}
\ No newline at end of file