[java-identity-provider] branch master updated: IDP-1177 - Centralize deprecation warnings through dedicated function

Scott Cantor cantor.2 at osu.edu
Sat Jun 3 19:07:05 EDT 2017


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

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

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

The following commit(s) were added to refs/heads/master by this push:
       new  9ee5d52   IDP-1177 - Centralize deprecation warnings through dedicated function
9ee5d52 is described below

commit 9ee5d520b8ea03c4d2923b076f4ada46e0a07467
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Sat Jun 3 19:07:02 2017 -0400

    IDP-1177 - Centralize deprecation warnings through dedicated function
    
    https://issues.shibboleth.net/jira/browse/IDP-1177
    
    Property deprecation bean.
---
 .../src/main/resources/conf/services.properties    |   1 -
 .../main/resources/system/conf/global-system.xml   |  12 +++
 .../idp/spring/DeprecatedPropertyBean.java         | 117 +++++++++++++++++++++
 3 files changed, 129 insertions(+), 1 deletion(-)

diff --git a/idp-conf/src/main/resources/conf/services.properties b/idp-conf/src/main/resources/conf/services.properties
index 0f435cc..34ac41d 100644
--- a/idp-conf/src/main/resources/conf/services.properties
+++ b/idp-conf/src/main/resources/conf/services.properties
@@ -50,7 +50,6 @@ idp.service.cas.registry.checkInterval = PT15M
 # Parameters for pre-defined HttpClient instances which perform in-memory and filesystem caching.
 # These are used with components such as remote configuration resources that are explicitly wired
 # with these client instances, *not* by default with HTTP metadata resolvers.
-#idp.httpclient.useTrustEngineTLSSocketFactory = false
 #idp.httpclient.useSecurityEnhancedTLSSocketFactory = false
 #idp.httpclient.connectionDisregardTLSCertificate = false
 #idp.httpclient.connectionRequestTimeout = PT1M
diff --git a/idp-conf/src/main/resources/system/conf/global-system.xml b/idp-conf/src/main/resources/system/conf/global-system.xml
index b2de4b9..1e2bd1f 100644
--- a/idp-conf/src/main/resources/system/conf/global-system.xml
+++ b/idp-conf/src/main/resources/system/conf/global-system.xml
@@ -54,6 +54,18 @@
         depends-on="shibboleth.LoggingService,shibboleth.ParserPool,shibboleth.metrics.MetricRegistry"
         p:parserPool-ref="shibboleth.ParserPool"
         p:metricRegistry-ref="shibboleth.metrics.MetricRegistry" />
+        
+    <bean class="net.shibboleth.idp.spring.DeprecatedPropertyBean">
+        <property name="deprecatedProperties">
+            <map>
+                <entry key="idp.httpclient.useTrustEngineTLSSocketFactory" value="idp.httpclient.useSecurityEnhancedTLSSocketFactory" />
+            </map>
+        </property>
+        <property name="deadProperties">
+            <list>
+            </list>
+        </property>
+    </bean>
 
     <bean id="shibboleth.VelocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"
             depends-on="shibboleth.LoggingService">
diff --git a/idp-core/src/main/java/net/shibboleth/idp/spring/DeprecatedPropertyBean.java b/idp-core/src/main/java/net/shibboleth/idp/spring/DeprecatedPropertyBean.java
new file mode 100644
index 0000000..b4f2d04
--- /dev/null
+++ b/idp-core/src/main/java/net/shibboleth/idp/spring/DeprecatedPropertyBean.java
@@ -0,0 +1,117 @@
+/*
+ * 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 net.shibboleth.idp.spring;
+
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.component.AbstractInitializableComponent;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport;
+import net.shibboleth.utilities.java.support.primitive.DeprecationSupport.ObjectType;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+
+
+/**
+ * A simple bean that may be used with Spring to initialize the OpenSAML library
+ * with injected instances of some critical objects.
+ */
+public class DeprecatedPropertyBean extends AbstractInitializableComponent implements ApplicationContextAware {
+
+    /** Class logger. */
+    @Nonnull private final Logger log = LoggerFactory.getLogger(DeprecationSupport.LOG_CATEGORY);
+    
+    /** Spring context. */
+    @Nonnull private ApplicationContext applicationContext;
+    
+    /** Deprecated properties. */
+    @Nonnull private Map<String,String> deprecatedProperties;
+
+    /** Dead properties. */
+    @Nonnull @NonnullElements private Collection<String> deadProperties;
+
+    /** Constructor. */
+    public DeprecatedPropertyBean() {
+        deprecatedProperties = Collections.emptyMap();
+        deadProperties = Collections.emptyList();
+    }
+    
+    /**
+     * Set the property names to deprecate, along with an optional replacement.
+     * 
+     * @param map deprecated property names and replacements
+     */
+    public void setDeprecatedProperties(@Nonnull final Map<String,String> map) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        Constraint.isNotNull(map, "Property map cannot be null");
+        
+        deprecatedProperties = new HashMap<>(map.size());
+        for (final Map.Entry<String,String> entry : map.entrySet()) {
+            deprecatedProperties.put(StringSupport.trimOrNull(entry.getKey()),
+                    StringSupport.trimOrNull(entry.getValue()));
+        }
+    }
+    
+    /**
+     * Set the property names to treat as defunct.
+     * 
+     * @param properties defunct property names
+     */
+    public void setDeadProperties(@Nonnull @NonnullElements final Collection<String> properties) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        Constraint.isNotNull(properties, "Property collection cannot be null");
+        
+        deadProperties = StringSupport.normalizeStringCollection(properties);
+    }
+
+    /** {@inheritDoc} */
+    public void setApplicationContext(final ApplicationContext context) {
+        applicationContext = Constraint.isNotNull(context, "ApplicationContext cannot be null");
+    }
+    
+    /** {@inheritDoc} */
+    @Override
+    protected void doInitialize() throws ComponentInitializationException {
+        
+        for (final Map.Entry<String,String> entry : deprecatedProperties.entrySet()) {
+            if (applicationContext.getEnvironment().containsProperty(entry.getKey())) {
+                DeprecationSupport.warn(ObjectType.PROPERTY, entry.getKey(), null, entry.getValue());
+            }
+        }
+
+        for (final String name : deadProperties) {
+            if (applicationContext.getEnvironment().containsProperty(name)) {
+                log.warn("property '{}' is no longer supported", name);
+            }
+        }
+    }
+    
+}
\ No newline at end of file

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


More information about the commits mailing list