[java-identity-provider COMMIT] /trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationConte...

noreply at shibboleth.net noreply at shibboleth.net
Mon Oct 6 12:04:50 EDT 2014


Author: scantor
Date: Mon Oct  6 12:04:49 2014
New Revision: 6636

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=6636&view=rev
Log:
- Add support for loading additional properties through an indirected property.
- Suppress logging of "credential" properties.

Modified:
    trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java

Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java?rev=6636&r1=6635&r2=6636&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/spring/IdPPropertiesApplicationContextInitializer.java Mon Oct  6 12:04:49 2014
@@ -26,7 +26,9 @@
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,7 +49,10 @@
         ApplicationContextInitializer<ConfigurableApplicationContext> {
 
     /** IdP home property. */
-    @Nonnull public static final String IDP_HOME_PROPERTY = "idp.home";
+    @Nonnull @NotEmpty public static final String IDP_HOME_PROPERTY = "idp.home";
+    
+    /** Property that points to more property sources. */
+    @Nonnull @NotEmpty public static final String IDP_ADDITIONAL_PROPERTY = "idp.additionalProperties";
 
     /** Target resource to be searched for. */
     @Nonnull public static final String IDP_PROPERTIES = "/conf/idp.properties";
@@ -59,6 +64,7 @@
     /** Class logger. */
     @Nonnull private final Logger log = LoggerFactory.getLogger(IdPPropertiesApplicationContextInitializer.class);
 
+// Checkstyle: CyclomaticComplexity OFF
     /** {@inheritDoc} */
     @Override public void initialize(@Nonnull final ConfigurableApplicationContext applicationContext) {
         log.debug("Initializing application context '{}'", applicationContext);
@@ -74,7 +80,7 @@
             if (resource.exists()) {
                 log.debug("Found resource '{}' at search path '{}'", resource, searchPath);
 
-                final Properties properties = loadProperties(resource);
+                final Properties properties = loadProperties(null, resource);
                 if (properties == null) {
                     log.warn("Unable to load properties from resource '{}'", resource);
                     return;
@@ -86,7 +92,32 @@
                     final String searchLocationAbsolutePath = Paths.get(searchLocation).toAbsolutePath().toString();
                     setIdPHomeProperty(searchLocationAbsolutePath, properties);
                 }
-
+                
+                // Load any additional property sources.
+                final String additionalSources = properties.getProperty(IDP_ADDITIONAL_PROPERTY);
+                if (additionalSources != null) {
+                    final String[] sources = additionalSources.split(",");
+                    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);
+                        if (additionalResource.exists()) {
+                            log.debug("Found resource '{}' at search path '{}'", additionalResource, pathifiedSource);
+                            if (loadProperties(properties, additionalResource) == null) {
+                                log.warn("Unable to load properties from resource '{}'", additionalResource);
+                                continue;
+                            }
+                        } else {
+                            log.warn("Unable to find resource '{}'", additionalResource);
+                        }
+                    }
+                }
+
+                logProperties(properties);
                 final PropertiesPropertySource propertySource =
                         new PropertiesPropertySource(resource.toString(), properties);
 
@@ -98,6 +129,7 @@
 
         log.warn("Unable to find '{}' at well known locations '{}'", getSearchTarget(), getSearchLocations());
     }
+// Checkstyle: CyclomaticComplexity ON
 
     /**
      * Get the target resource to be searched for {@link #IDP_PROPERTIES}.
@@ -121,25 +153,39 @@

[... 50 lines stripped ...]


More information about the commits mailing list