use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultConfigurationService method getAllPublicConfigurations.
/**
* Returns all public configuration properties
*
* @return
*/
@Override
@Transactional(readOnly = true)
public List<IdmConfigurationDto> getAllPublicConfigurations() {
Map<String, Object> configurations = new HashMap<>();
// defaults from property file
Map<String, Object> map = getAllProperties(env);
for (Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (key.startsWith(IDM_PUBLIC_PROPERTY_PREFIX)) {
configurations.put(key, entry.getValue());
}
}
// override from database
repository.findAllBySecuredIsFalse().forEach(idmConfiguration -> {
configurations.put(idmConfiguration.getName(), idmConfiguration.getValue());
});
List<IdmConfigurationDto> results = new ArrayList<>();
configurations.forEach((k, v) -> {
results.add(toConfigurationDto(k, v));
});
return results;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultConfigurationService method deleteValue.
@Override
@Transactional
public String deleteValue(String key) {
IdmConfigurationDto dto = getByCode(key);
if (dto == null) {
return null;
}
delete(dto);
return dto.getValue();
}
use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultConfigurationService method saveConfiguration.
@Override
@Transactional
public void saveConfiguration(IdmConfigurationDto configuration) {
Assert.notNull(configuration);
Assert.hasText(configuration.getName());
// only maps dto to entity
IdmConfigurationDto configurationEntity = getByCode(configuration.getName());
if (configurationEntity == null) {
configurationEntity = new IdmConfigurationDto(configuration.getName(), configuration.getValue(), configuration.isSecured(), configuration.isConfidential());
} else {
configurationEntity.setValue(configuration.getValue());
configurationEntity.setSecured(configuration.isSecured());
configurationEntity.setConfidential(configuration.isConfidential());
}
save(configurationEntity);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.
the class DefaultConfigurationService method getValue.
@Override
@Transactional(readOnly = true)
public String getValue(String key, String defaultValue) {
ValueWrapper cachedValue = getCachedValue(key);
if (cachedValue != null) {
String value = (String) cachedValue.get();
return value != null ? value : defaultValue;
}
//
LOG.debug("Reading configuration for key [{}]", key);
String value = null;
boolean confidential = true;
// idm configuration has higher priority than property file
IdmConfigurationDto config = getByCode(key);
if (config != null) {
if (config.isConfidential()) {
value = confidentialStorage.get(config.getId(), getEntityClass(), CONFIDENTIAL_PROPERTY_VALUE, String.class);
LOG.debug("Configuration value for key [{}] was found in confidential storage", config.getName());
} else {
value = config.getValue();
confidential = false;
LOG.trace("Configuration value for key [{}] was found in database.", key);
}
} else if (env != null) {
// try to find value in property configuration
value = env.getProperty(key);
confidential = shouldBeConfidential(key);
}
// fill default value
if (value == null) {
value = defaultValue;
}
LOG.debug("Resolved configuration value for key [{}] is [{}].", key, confidential ? GuardedString.SECRED_PROXY_STRING : value);
setCachedValue(key, value);
return value;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmConfigurationDto in project CzechIdMng by bcvsolutions.
the class PreserveUuidIntegrationTest method testIsNewWithoutId.
@Test
public void testIsNewWithoutId() {
IdmConfigurationDto configuration = new IdmConfigurationDto();
configuration.setName("test-property-one");
configuration.setValue("one");
//
assertTrue(configurationService.isNew(configuration));
}
Aggregations