in our environment, we - for development put all properties in our application-dev.properties file.
in our upstream environments - we add a startup parameter (-Dsecurity.file=somefile). which has the encrypted properties
our configuration file for the non dev envionments has the following:
@EncryptablePropertySource(value = "file:${security.file}", ignoreResourceNotFound = true)
this fails as security.file is not defined in our dev environments.
Assume the fix is: in EncryptablePropertySourceBeanFactoryPostProcessor
something like:
private PropertySource createPropertySource(AnnotationAttributes attributes, ConfigurableEnvironment environment, ResourceLoader resourceLoader, EncryptablePropertyResolver resolver, List loaders) throws Exception {
String name = generateName(attributes.getString("name"));
String[] locations = attributes.getStringArray("value");
boolean ignoreResourceNotFound = attributes.getBoolean("ignoreResourceNotFound");
CompositePropertySource compositePropertySource = new CompositePropertySource(name);
Assert.isTrue(locations.length > 0, "At least one @PropertySource(value) location is required");
try{
for (String location : locations) {
String resolvedLocation = environment.resolveRequiredPlaceholders(location);
Resource resource = resourceLoader.getResource(resolvedLocation);
if (!resource.exists()) {
if (!ignoreResourceNotFound) {
throw new IllegalStateException(String.format("Encryptable Property Source '%s' from location: %s Not Found", name, resolvedLocation));
} else {
log.info("Ignoring NOT FOUND Encryptable Property Source '{}' from locations: {}", name, resolvedLocation);
}
} else {
String actualName = name + "#" + resolvedLocation;
loadPropertySource(loaders, resource, actualName)
.ifPresent(compositePropertySource::addPropertySource);
}
}
}
catch (Exception e){
if(!ignoreResourceNotFound){
log.warn("the % is not defined - ignoring the property file",locations.toString());
throw e;
}
}
return new EncryptableEnumerablePropertySourceWrapper<>(compositePropertySource, resolver);
}
in our environment, we - for development put all properties in our application-dev.properties file. in our upstream environments - we add a startup parameter (-Dsecurity.file=somefile). which has the encrypted properties
our configuration file for the non dev envionments has the following: @EncryptablePropertySource(value = "file:${security.file}", ignoreResourceNotFound = true)
this fails as security.file is not defined in our dev environments.
Assume the fix is: in EncryptablePropertySourceBeanFactoryPostProcessor
something like:
private PropertySource createPropertySource(AnnotationAttributes attributes, ConfigurableEnvironment environment, ResourceLoader resourceLoader, EncryptablePropertyResolver resolver, List loaders) throws Exception {
String name = generateName(attributes.getString("name"));
String[] locations = attributes.getStringArray("value");
boolean ignoreResourceNotFound = attributes.getBoolean("ignoreResourceNotFound");
CompositePropertySource compositePropertySource = new CompositePropertySource(name);
Assert.isTrue(locations.length > 0, "At least one @PropertySource(value) location is required");
try{
for (String location : locations) {
String resolvedLocation = environment.resolveRequiredPlaceholders(location);
Resource resource = resourceLoader.getResource(resolvedLocation);
if (!resource.exists()) {
if (!ignoreResourceNotFound) {
throw new IllegalStateException(String.format("Encryptable Property Source '%s' from location: %s Not Found", name, resolvedLocation));
} else {
log.info("Ignoring NOT FOUND Encryptable Property Source '{}' from locations: {}", name, resolvedLocation);
}
} else {
String actualName = name + "#" + resolvedLocation;
loadPropertySource(loaders, resource, actualName)
.ifPresent(compositePropertySource::addPropertySource);
}
}
}
catch (Exception e){
if(!ignoreResourceNotFound){
log.warn("the % is not defined - ignoring the property file",locations.toString());
throw e;
}
}
return new EncryptableEnumerablePropertySourceWrapper<>(compositePropertySource, resolver);
}