[java-identity-provider] branch main updated: IDP-1671 - Eliminate need to manually identify standard property sources

Scott Cantor cantor.2 at osu.edu
Thu Sep 3 20:14:28 UTC 2020


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=194d9f5a5a584d61285a24102bef99e924c7bdf5

The following commit(s) were added to refs/heads/main by this push:
       new  194d9f5a5 IDP-1671 - Eliminate need to manually identify standard property sources
194d9f5a5 is described below

commit 194d9f5a5a584d61285a24102bef99e924c7bdf5
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Sep 3 16:14:19 2020 -0400

    IDP-1671 - Eliminate need to manually identify standard property sources
    
    https://issues.shibboleth.net/jira/browse/IDP-1671
    
    Bug fix, avoid prepending idp.home to auto-located files.
---
 ...IdPPropertiesApplicationContextInitializer.java | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java b/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
index a928651c8..3a5421d4f 100644
--- a/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
+++ b/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
@@ -25,7 +25,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Properties;
 import java.util.TreeSet;
@@ -212,6 +211,7 @@ public class IdPPropertiesApplicationContextInitializer
         }
     }
 
+// Checkstyle: CyclomaticComplexity OFF
     /**
      * Load additional property sources.
      * 
@@ -236,7 +236,8 @@ public class IdPPropertiesApplicationContextInitializer
                 try (final Stream<Path> paths = Files.find(searchRoot, Integer.MAX_VALUE,
                         new BiPredicate<Path,BasicFileAttributes>() {
                                 public boolean test(final Path t, final BasicFileAttributes u) {
-                                    if (u.isRegularFile() && t.getFileName().toString().endsWith(".properties")) {
+                                    if (u.isRegularFile() && t.getFileName().toString().endsWith(".properties")
+                                            && !t.endsWith(Path.of(IDP_PROPERTIES))) {
                                         log.debug("Including auto-located properties in {}", t);
                                         return true;
                                     }
@@ -253,19 +254,20 @@ public class IdPPropertiesApplicationContextInitializer
         
         final String additionalSources = properties.getProperty(IDP_ADDITIONAL_PROPERTY);
         if (additionalSources != null) {
-            sources.addAll(Arrays.asList(additionalSources.split(",")));
+            final String[] split = additionalSources.split(",");
+            for (final String s : split) {
+                final String trimmedSource = StringSupport.trimOrNull(s);
+                if (trimmedSource != null) {
+                    sources.add(searchLocation + trimmedSource);
+                }
+            }
         }
         
         for (final String source : sources) {
-            final String trimmedSource = StringSupport.trimOrNull(source);
-            if (trimmedSource == null) {
-                continue;
-            }
-            log.debug("Attempting to load properties from resource '{}'", trimmedSource);
-            final String pathifiedSource = searchLocation + trimmedSource;
-            final Resource additionalResource = applicationContext.getResource(pathifiedSource);
+            log.debug("Attempting to load properties from resource '{}'", source);
+            final Resource additionalResource = applicationContext.getResource(source);
             if (additionalResource.exists()) {
-                log.debug("Found resource '{}' at search path '{}'", additionalResource, pathifiedSource);
+                log.debug("Found property resource '{}'", additionalResource);
                 if (loadProperties(properties, additionalResource) == null) {
                     if (isFailFast(applicationContext)) {
                         log.error("Unable to load properties from resource '{}'", additionalResource);
@@ -275,11 +277,12 @@ public class IdPPropertiesApplicationContextInitializer
                     continue;
                 }
             } else {
-                log.warn("Unable to find resource '{}'", additionalResource);
+                log.warn("Unable to find property resource '{}'", additionalResource);
             }
         }
     }
-
+// Checkstyle: CyclomaticComplexity ON
+    
     /**
      * Log property names and values at debug level, suppressing properties whose name matches 'password',
      * 'credential', 'secret', or 'salt'.

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


More information about the commits mailing list