[java-shib-shared] branch main updated: JSSH-51 - Context initializer fails on external property search values
Scott Cantor
cantor.2 at osu.edu
Wed Jul 3 14:55:32 UTC 2024
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=740d5808430df50e6821e98a962bb533520cc9d0
The following commit(s) were added to refs/heads/main by this push:
new 740d5808 JSSH-51 - Context initializer fails on external property search values
740d5808 is described below
commit 740d5808430df50e6821e98a962bb533520cc9d0
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Jul 3 10:55:29 2024 -0400
JSSH-51 - Context initializer fails on external property search values
https://shibboleth.atlassian.net/browse/JSSH-51
---
...actPropertiesApplicationContextInitializer.java | 25 ++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/shib-spring/src/main/java/net/shibboleth/shared/spring/context/AbstractPropertiesApplicationContextInitializer.java b/shib-spring/src/main/java/net/shibboleth/shared/spring/context/AbstractPropertiesApplicationContextInitializer.java
index 19e65568..bb131cbc 100644
--- a/shib-spring/src/main/java/net/shibboleth/shared/spring/context/AbstractPropertiesApplicationContextInitializer.java
+++ b/shib-spring/src/main/java/net/shibboleth/shared/spring/context/AbstractPropertiesApplicationContextInitializer.java
@@ -43,6 +43,7 @@ import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
+import io.micrometer.common.util.StringUtils;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
@@ -256,18 +257,26 @@ public abstract class AbstractPropertiesApplicationContextInitializer
/**
* Find out all the additional property files we need to load.
- *
+ *
+ * @param applicationContext the application context
* @param searchLocation Where to search from
* @param properties the content of idp.properties so far
*
* @return a collection of paths
*/
@Nonnull @Unmodifiable @NotLive protected Collection<String> getAdditionalSources(
- @Nonnull final String searchLocation, @Nonnull final Properties properties) {
+ @Nonnull final ConfigurableApplicationContext applicationContext, @Nonnull final String searchLocation,
+ @Nonnull final Properties properties) {
final Collection<String> sources = new ArrayList<>();
- final Boolean autosearch = Boolean.valueOf(properties.getProperty(getAutoSearchPropertyName(), "false"));
+ // Favor existing property in the chain, then the local property value for auto-search.
+ @SuppressWarnings("null")
+ final Boolean autosearch = Boolean.valueOf(
+ applicationContext.getEnvironment().getProperty(getAutoSearchPropertyName(),
+ properties.getProperty(getAutoSearchPropertyName(), "false")));
+
if (autosearch) {
+ LOG.debug("Configured to autosearch for property files");
final Path searchRoot = Path.of(searchLocation).resolve("conf");
if (searchRoot.toFile().isDirectory()) {
final Path registryRoot = searchRoot.resolve("attributes");
@@ -295,8 +304,12 @@ public abstract class AbstractPropertiesApplicationContextInitializer
}
}
- final String additionalSources = properties.getProperty(getAdditionalPropertiesPropertyName());
- if (additionalSources != null) {
+ // Favor existing property in the chain, then the local property value for additional property locations.
+ @SuppressWarnings("null")
+ final String additionalSources =
+ applicationContext.getEnvironment().getProperty(getAdditionalPropertiesPropertyName(),
+ properties.getProperty(getAdditionalPropertiesPropertyName(), ""));
+ if (StringUtils.isNotBlank(additionalSources)) {
final String[] split = additionalSources.split(",");
for (final String s : split) {
final String trimmedSource = StringSupport.trimOrNull(s);
@@ -323,7 +336,7 @@ public abstract class AbstractPropertiesApplicationContextInitializer
protected void loadAdditionalPropertySources(@Nonnull final ConfigurableApplicationContext applicationContext,
@Nonnull final String searchLocation, @Nonnull final Properties properties) {
- for (final String source : getAdditionalSources(searchLocation, properties)) {
+ for (final String source : getAdditionalSources(applicationContext, searchLocation, properties)) {
assert source != null;
LOG.debug("Attempting to load properties from resource '{}'", source);
final Resource additionalResource = applicationContext.getResource(source);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list