[java-opensaml] 01/02: OSJ-338: Add ConfigurationPropertiesSource based on system props, and default it.
Brent Putman
putmanb at georgetown.edu
Tue Jul 27 03:14:18 UTC 2021
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=6e5d193e9139b6daa2eaa0857cab96cedc0550cd
commit 6e5d193e9139b6daa2eaa0857cab96cedc0550cd
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Tue Jul 20 18:47:02 2021 -0400
OSJ-338: Add ConfigurationPropertiesSource based on system props, and default it.
---
.../opensaml/core/config/ConfigurationService.java | 7 +++++
...ystemPropertyConfigurationPropertiesSource.java | 34 ++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/opensaml-core/src/main/java/org/opensaml/core/config/ConfigurationService.java b/opensaml-core/src/main/java/org/opensaml/core/config/ConfigurationService.java
index 5cb71b1e8..992f54ff6 100644
--- a/opensaml-core/src/main/java/org/opensaml/core/config/ConfigurationService.java
+++ b/opensaml-core/src/main/java/org/opensaml/core/config/ConfigurationService.java
@@ -28,6 +28,7 @@ import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
import net.shibboleth.utilities.java.support.logic.Constraint;
import org.opensaml.core.config.provider.MapBasedConfiguration;
+import org.opensaml.core.config.provider.SystemPropertyConfigurationPropertiesSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -139,6 +140,12 @@ public class ConfigurationService {
final Logger log = getLogger();
log.trace("Resolving configuration propreties source");
final Iterator<ConfigurationPropertiesSource> iter = configPropertiesLoader.iterator();
+
+ if (!iter.hasNext()) {
+ log.trace("No ConfigurationPropertiesSources are configured, defaulting to system properties");
+ return new SystemPropertyConfigurationPropertiesSource().getProperties();
+ }
+
while (iter.hasNext()) {
final ConfigurationPropertiesSource source = iter.next();
log.trace("Evaluating configuration properties implementation: {}", source.getClass().getName());
diff --git a/opensaml-core/src/main/java/org/opensaml/core/config/provider/SystemPropertyConfigurationPropertiesSource.java b/opensaml-core/src/main/java/org/opensaml/core/config/provider/SystemPropertyConfigurationPropertiesSource.java
new file mode 100644
index 000000000..c6afd9e1c
--- /dev/null
+++ b/opensaml-core/src/main/java/org/opensaml/core/config/provider/SystemPropertyConfigurationPropertiesSource.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.core.config.provider;
+
+import java.util.Properties;
+
+import org.opensaml.core.config.ConfigurationPropertiesSource;
+
+/**
+ * A configuration properties source implementation which simply returns the system properties set.
+ */
+public class SystemPropertyConfigurationPropertiesSource implements ConfigurationPropertiesSource {
+
+ /** {@inheritDoc} */
+ public Properties getProperties() {
+ return System.getProperties();
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list