Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit bb752496 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

PR Updates

parent dd0a0a7d
No related branches found
No related tags found
No related merge requests found
Showing
with 412 additions and 270 deletions
......@@ -89,7 +89,7 @@ public class ConfigurationDao extends BaseDao<DBConfiguration> {
@Transactional
public DBConfiguration setPropertyToDatabase(SMPPropertyEnum key, String value, String description) {
File rootFolder = (File)getCachedPropertyValue(CONFIGURATION_DIR);
File rootFolder = getCachedPropertyValue(CONFIGURATION_DIR);
if (!PropertyUtils.isValidProperty(key, value, rootFolder)) {
throw new SMPRuntimeException(ErrorCode.CONFIGURATION_ERROR, key.getPropertyType().getErrorMessage(key.getProperty()));
}
......@@ -155,12 +155,12 @@ public class ConfigurationDao extends BaseDao<DBConfiguration> {
return cachedProperties.getProperty(property, defValue);
}
public Object getCachedPropertyValue(SMPPropertyEnum key) {
public <T extends Object> T getCachedPropertyValue(SMPPropertyEnum key) {
if (lastUpdate == null) {
// init properties
refreshProperties();
}
return cachedPropertyValues.get(key.getProperty());
return (T) cachedPropertyValues.get(key.getProperty());
}
@Transactional
......
......@@ -2,7 +2,7 @@ package eu.europa.ec.edelivery.smp.data.ui.enums;
/**
* Enumeraton of Resourceobject statuse .
* Enumeration of Resource Object status.
* @author Joze Rihtarsic
* @since 4.1
*/
......
package eu.europa.ec.edelivery.smp.data.ui.enums;
/**
* Enumeration constants. The purpose of the constants is to make enumeration configurations more transparent/readable
* ex:
* This is (see the boolean values)
* OUTPUT_CONTEXT_PATH("contextPath.output", "true", "This property controls pattern of URLs produced by SMP in GET ServiceGroup responses.",
* true, false, true, BOOLEAN),
* changed to:
* OUTPUT_CONTEXT_PATH("contextPath.output", "true", "This property controls pattern of URLs produced by SMP in GET ServiceGroup responses.",
* MANDATORY, NOT_ENCRYPTED, RESTART_NEEDED, BOOLEAN),
*
* @author Joze Rihtarsic
* @since 4.2
*/
public class SMPEnumConstants {
public static final boolean MANDATORY = true;
public static final boolean OPTIONAL = !MANDATORY;
public static final boolean ENCRYPTED = true;
public static final boolean NOT_ENCRYPTED = !ENCRYPTED;
public static final boolean RESTART_NEEDED = true;
public static final boolean NO_RESTART_NEEDED = !RESTART_NEEDED;
}
......@@ -116,7 +116,7 @@ public class UIPropertyService {
for (PropertyRO property : properties) {
configurationDao.setPropertyToDatabase(property.getProperty(), property.getValue());
}
Boolean isClusterEnabled = (Boolean) configurationDao.getCachedPropertyValue(SMP_CLUSTER_ENABLED);
Boolean isClusterEnabled = configurationDao.getCachedPropertyValue(SMP_CLUSTER_ENABLED);
if (isClusterEnabled) {
LOG.info("Properties were updated in database. Changed properties will be activated to all cluster nodes at: [{}]!",
ISO_8601_EXTENDED_DATETIME_FORMAT.format(refreshPropertiesTrigger.getNextExecutionDate()));
......@@ -147,7 +147,7 @@ public class UIPropertyService {
// try to parse value
try {
File confDir = (File) configurationDao.getCachedPropertyValue(CONFIGURATION_DIR);
File confDir = configurationDao.getCachedPropertyValue(CONFIGURATION_DIR);
PropertyUtils.parseProperty(propertyEnum, propertyRO.getValue(), confDir);
} catch (SMPRuntimeException ex) {
propertyValidationRO.setErrorMessage(ex.getMessage());
......
......@@ -377,18 +377,17 @@ public class UITruststoreService {
return null;
}
KeyStore truststore;
try (InputStream truststoreInputStream = new FileInputStream(truststoreFile)) {
String type = StringUtils.defaultIfEmpty(configurationService.getTruststoreType(),"JKS");
LOG.info("Load truststore [{}] with type [{}].", truststoreFile, type);
truststore = KeyStore.getInstance(type);
truststore.load(truststoreInputStream, token.toCharArray());
KeyStore loadedTrustStore = KeyStore.getInstance(type);
loadedTrustStore.load(truststoreInputStream, token.toCharArray());
return loadedTrustStore;
} catch (Exception exception) {
LOG.error("Could not load truststore:"
+ truststoreFile + " Error: " + ExceptionUtils.getRootCauseMessage(exception), exception);
truststore = null;
}
return truststore;
return null;
}
......
......@@ -284,7 +284,7 @@ public class ConfigurationDAOImplTest extends AbstractBaseDao {
assertEquals(newTestPassword, configurationDao.getCachedPropertyValue(SMPPropertyEnum.HTTP_PROXY_PASSWORD));
// test decrypt
File encryptionKey = (File) configurationDao.getCachedPropertyValue(SMPPropertyEnum.ENCRYPTION_FILENAME);
File encryptionKey = configurationDao.getCachedPropertyValue(SMPPropertyEnum.ENCRYPTION_FILENAME);
assertEquals(newTestPassword, configurationDao.decryptString(SMPPropertyEnum.KEYSTORE_PASSWORD, dbKeystorePassword, encryptionKey));
assertEquals(newTestPassword, configurationDao.decryptString(SMPPropertyEnum.TRUSTSTORE_PASSWORD, dbTruststorePassword, encryptionKey));
assertEquals(newTestPassword, configurationDao.decryptString(SMPPropertyEnum.HTTP_PROXY_PASSWORD, dbProxyPassword, encryptionKey));
......
......@@ -70,9 +70,8 @@ public class KeystoreResource {
payloadValidatorService.validateUploadedContent(new ByteArrayInputStream(fileBytes), MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE);
// try to open keystore
KeystoreImportResult keystoreImportResult = new KeystoreImportResult();
KeyStore keyStore;
try {
keyStore = KeyStore.getInstance(keystoreType);
KeyStore keyStore = KeyStore.getInstance(keystoreType);
keyStore.load(new ByteArrayInputStream(fileBytes), password.toCharArray());
LOG.debug(keyStore.aliases().nextElement());
uiKeystoreService.importKeys(keyStore, password);
......
-- ------------------------------------------------------------------------
-- This file was generated by hibernate for SMP version 4.2-RC2-SNAPSHOT.
-- This file was generated by hibernate for SMP version 5.0-SNAPSHOT.
-- ------------------------------------------------------------------------
......
-- ------------------------------------------------------------------------
-- This file was generated by hibernate for SMP version 4.2-RC2-SNAPSHOT.
-- This file was generated by hibernate for SMP version 5.0-SNAPSHOT.
-- ------------------------------------------------------------------------
......
-- ------------------------------------------------------------------------
-- This file was generated by hibernate for SMP version 4.2-RC2-SNAPSHOT.
-- This file was generated by hibernate for SMP version 5.0-SNAPSHOT.
-- ------------------------------------------------------------------------
......
-- ------------------------------------------------------------------------
-- This file was generated by hibernate for SMP version 4.2-RC2-SNAPSHOT.
-- This file was generated by hibernate for SMP version 5.0-SNAPSHOT.
-- ------------------------------------------------------------------------
create sequence SMP_ALERT_PROP_SEQ start with 1 increment by 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment