Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-keycloak-link): unstatisfied dependencies #10627

Merged
merged 2 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions jans-keycloak-link/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-service</artifactId>
<exclusions>
<exclusion>
<groupId>io.jans</groupId>
<artifactId>jans-core-document-store</artifactId>
</exclusion>
<exclusion>
<groupId>io.jans</groupId>
<artifactId>jans-core-message</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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;
}
}
Loading