[java-shib-shared] branch main updated: IDP-2367 - Upgrade breaks use of attributes.properties via idp.searchForProperties

Scott Cantor cantor.2 at osu.edu
Wed Mar 26 17:45:23 UTC 2025


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=819a56435d0aa91ec1819bf628928727c8173c63

The following commit(s) were added to refs/heads/main by this push:
     new 819a5643 IDP-2367 - Upgrade breaks use of attributes.properties via idp.searchForProperties
819a5643 is described below

commit 819a56435d0aa91ec1819bf628928727c8173c63
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 26 13:45:20 2025 -0400

    IDP-2367 - Upgrade breaks use of attributes.properties via
    idp.searchForProperties
    
    https://shibboleth.atlassian.net/browse/IDP-2367
    
    Fix filtering logic and remove IdP specifics from class.
---
 ...actPropertiesApplicationContextInitializer.java | 44 +++++++++++++++++++---
 1 file changed, 39 insertions(+), 5 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 bb131cbc..6d470c38 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
@@ -47,6 +47,7 @@ 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;
+import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 import net.shibboleth.shared.primitive.LoggerFactory;
@@ -122,6 +123,33 @@ public abstract class AbstractPropertiesApplicationContextInitializer
      */
     @Nonnull @NotEmpty protected abstract String getAutoSearchPropertyName();
     
+    /**
+     * Get the root folder under the search location to search for additional property files.
+     * 
+     * TODO: Make abstract in 6.0.0.
+     * 
+     * @return search root folder name
+     * 
+     * @since 5.2.0
+     */
+    @Nonnull @NotEmpty protected String getAutoSearchRoot() {
+        return "conf";
+    }
+    
+    /**
+     * Get the collection of paths under the search root to exclude when searching for
+     * additional property files.
+     * 
+     * TODO: Make abstract in 6.0.0.
+     * 
+     * @return excluded folders under the search root
+     * 
+     * @since 5.2.0
+     */
+    @Nonnull @NotEmpty protected Collection<String> getExcludedSearchPaths() {
+        return CollectionSupport.singletonList("attributes");
+    }
+
     /**
      * Get the name of the property to populate with duplicates detected.
      * 
@@ -129,7 +157,7 @@ public abstract class AbstractPropertiesApplicationContextInitializer
      * 
      * @since 9.1.0
      */
-    @Nonnull @NotEmpty protected abstract String getDuplicateWarningPropertyName(); 
+    @Nonnull @NotEmpty protected abstract String getDuplicateWarningPropertyName();
 
     /** {@inheritDoc} */
     public void initialize(@Nonnull final ConfigurableApplicationContext applicationContext) {
@@ -277,9 +305,11 @@ public abstract class AbstractPropertiesApplicationContextInitializer
        
        if (autosearch) {
            LOG.debug("Configured to autosearch for property files");
-           final Path searchRoot = Path.of(searchLocation).resolve("conf");
+           final Path searchRoot = Path.of(searchLocation).resolve(getAutoSearchRoot());
            if (searchRoot.toFile().isDirectory()) {
-               final Path registryRoot = searchRoot.resolve("attributes");
+               final Collection<Path> exclusions = getExcludedSearchPaths().stream()
+                       .map(s -> { return searchRoot.resolve(s); })
+                       .collect(CollectionSupport.nonnullCollector(Collectors.toUnmodifiableList())).get();
                final String idpPropertiesNative = Path.of(getSearchTarget()).toString();
                try (final Stream<Path> paths = Files.find(searchRoot, Integer.MAX_VALUE,
                        new BiPredicate<Path,BasicFileAttributes>() {
@@ -288,8 +318,12 @@ public abstract class AbstractPropertiesApplicationContextInitializer
                                    // convert back and forth to handle different dir separators
                                    if (u.isRegularFile()
                                            && path.getFileName().toString().endsWith(".properties")
-                                           && !pathAsString.endsWith(idpPropertiesNative)
-                                           && !pathAsString.startsWith(registryRoot.toString())) {
+                                           && !pathAsString.endsWith(idpPropertiesNative)) {
+                                       for (final Path exclusion : exclusions) {
+                                           if (pathAsString.startsWith(exclusion.toString() + File.separator)) {
+                                               return false;
+                                           }
+                                       }
                                        LOG.info("Including auto-located properties in {}", path);
                                        return true;
                                    }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list