use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.
the class ConfigResolver method filterConfigValueForLog.
/**
* Filter the configured value for logging.
* This can e.g. be used for displaying ***** instead of a real password.
* @return the filtered value
*/
public static String filterConfigValueForLog(String key, String value) {
List<ConfigFilter> currentConfigFilters = getInternalConfigFilters();
String logValue = value;
for (ConfigFilter filter : currentConfigFilters) {
logValue = filter.filterValueForLog(key, logValue);
}
return logValue;
}
use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.
the class ConfigResolver method filterConfigValue.
/**
* Filter the configured value.
* This can e.g. be used for decryption.
* @return the filtered value
*/
public static String filterConfigValue(String key, String value) {
List<ConfigFilter> currentConfigFilters = getInternalConfigFilters();
String filteredValue = value;
for (ConfigFilter filter : currentConfigFilters) {
filteredValue = filter.filterValue(key, filteredValue);
}
return filteredValue;
}
use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.
the class ConfigImpl method init.
/**
* Performs all the initialisation of the default
* ConfigSources, ConfigFilters, etc
*/
void init() {
List<ConfigSource> appConfigSources = ServiceUtils.loadServiceImplementations(ConfigSource.class, false, classLoader);
List<ConfigSourceProvider> configSourceProviderServiceLoader = ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class, false, classLoader);
for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader) {
appConfigSources.addAll(configSourceProvider.getConfigSources());
}
addConfigSources(appConfigSources);
if (LOG.isLoggable(Level.FINE)) {
for (ConfigSource cs : appConfigSources) {
LOG.log(Level.FINE, "Adding ordinal {0} ConfigSource {1}", new Object[] { cs.getOrdinal(), cs.getConfigName() });
}
}
List<ConfigFilter> configFilters = ServiceUtils.loadServiceImplementations(ConfigFilter.class, false, classLoader);
this.configFilters = new CopyOnWriteArrayList<>(configFilters);
}
use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.
the class ConfigResolverTest method testConfigFilter.
@Test
public void testConfigFilter() {
ConfigFilter configFilter = new TestConfigFilter();
Assert.assertEquals("shouldGetDecrypted: value", configFilter.filterValue("somekey.encrypted", "value"));
Assert.assertEquals("**********", configFilter.filterValueForLog("somekey.password", "value"));
ConfigResolver.addConfigFilter(configFilter);
Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyValue("testkey4.encrypted"));
Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted"));
Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted", null));
Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor"));
Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor", null));
List<String> allPropertyValues = ConfigResolver.getAllPropertyValues("testkey4.encrypted");
Assert.assertNotNull(allPropertyValues);
Assert.assertEquals(1, allPropertyValues.size());
Assert.assertEquals("shouldGetDecrypted: value", allPropertyValues.get(0));
}
use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.
the class ConfigResolver method resolveConfigSources.
private static List<ConfigSource> resolveConfigSources() {
List<ConfigSource> appConfigSources = ServiceUtils.loadServiceImplementations(ConfigSource.class);
List<ConfigSourceProvider> configSourceProviderServiceLoader = ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class);
for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader) {
appConfigSources.addAll(configSourceProvider.getConfigSources());
}
List<? extends ConfigFilter> configFilters = ServiceUtils.loadServiceImplementations(ConfigFilter.class);
for (ConfigFilter configFilter : configFilters) {
addConfigFilter(configFilter);
}
return appConfigSources;
}
Aggregations