[java-identity-provider] branch main updated: Auto-wire MetadataNodeProcessors.

Scott Cantor cantor.2 at osu.edu
Wed Oct 7 22:36:59 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=ba9db5ccfb41aee475af462becb39ebe7f029439

The following commit(s) were added to refs/heads/main by this push:
       new  ba9db5ccf Auto-wire MetadataNodeProcessors.
ba9db5ccf is described below

commit ba9db5ccfb41aee475af462becb39ebe7f029439
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 7 18:36:55 2020 -0400

    Auto-wire MetadataNodeProcessors.
---
 .../idp/conf/metadata-providers-system.xml         | 21 +++++++--------
 .../NodeProcessingAttachingBeanPostProcessor.java  | 30 +++++++++++++++++-----
 2 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metadata-providers-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metadata-providers-system.xml
index 39ae36169..e32828cb3 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metadata-providers-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/metadata-providers-system.xml
@@ -12,22 +12,23 @@
        default-init-method="initialize"
        default-destroy-method="destroy">
 
+    <context:annotation-config />
+
     <!-- BeanPostProcessors that auto-install MetadataFilters for internal use. -->
     
     <bean class="net.shibboleth.idp.profile.spring.relyingparty.metadata.impl.ByReferenceFilterBeanPostProcessor"
         p:enabled="%{idp.service.metadata.enableByReferenceFilters:true}" />
     
     <bean class="net.shibboleth.idp.profile.spring.relyingparty.metadata.impl.NodeProcessingAttachingBeanPostProcessor"
-        p:nodeProcessors="#{getObject('shibboleth.MetadataNodeProcessors') ?: getObject('shibboleth.DefaultMetadataNodeProcessors')}" />
-        
-    <util:list id="shibboleth.DefaultMetadataNodeProcessors">
-        <bean class="org.opensaml.saml.metadata.resolver.filter.impl.EntitiesDescriptorNameProcessor" />
-        <bean class="net.shibboleth.idp.saml.security.impl.KeyAuthorityNodeProcessor" />
-        <bean class="net.shibboleth.idp.saml.metadata.impl.ScopesNodeProcessor" />
-        <bean class="net.shibboleth.idp.saml.metadata.impl.UIInfoNodeProcessor" />
-        <bean class="net.shibboleth.idp.saml.metadata.impl.AttributeMappingNodeProcessor"
-            c:_0-ref="shibboleth.AttributeRegistryService" />
-    </util:list>
+        p:nodeProcessors="#{getObject('shibboleth.MetadataNodeProcessors')}" />
+
+    <!-- Default NodeProcessors to auto-wire. -->
+    <bean class="org.opensaml.saml.metadata.resolver.filter.impl.EntitiesDescriptorNameProcessor" />
+    <bean class="net.shibboleth.idp.saml.security.impl.KeyAuthorityNodeProcessor" />
+    <bean class="net.shibboleth.idp.saml.metadata.impl.ScopesNodeProcessor" />
+    <bean class="net.shibboleth.idp.saml.metadata.impl.UIInfoNodeProcessor" />
+    <bean class="net.shibboleth.idp.saml.metadata.impl.AttributeMappingNodeProcessor"
+        c:_0-ref="shibboleth.AttributeRegistryService" />
     
     <!-- Signature Validation Criteria  -->
     
diff --git a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
index 4b6140f7a..d49921b85 100644
--- a/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
+++ b/idp-profile-spring/src/main/java/net/shibboleth/idp/profile/spring/relyingparty/metadata/impl/NodeProcessingAttachingBeanPostProcessor.java
@@ -31,6 +31,7 @@ import org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain;
 import org.opensaml.saml.metadata.resolver.filter.MetadataNodeProcessor;
 import org.opensaml.saml.metadata.resolver.filter.impl.NodeProcessingMetadataFilter;
 import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.config.BeanPostProcessor;
 import org.springframework.core.Ordered;
 
@@ -45,19 +46,31 @@ import net.shibboleth.utilities.java.support.component.ComponentInitializationEx
  * This is done to ensure that other components function correctly, such as the PKIX trust engine and predicates that
  * depend on group information.
  * </p>
+ * 
+ * <p>The constructor will auto-wire all free-standing beans, but the property setter can override these.</p>
  */
 public class NodeProcessingAttachingBeanPostProcessor implements BeanPostProcessor, Ordered {
 
     /** The processors to install. */
     @Nonnull @NonnullElements private List<MetadataNodeProcessor> nodeProcessors;
-    
-    /** Constructor. */
-    public NodeProcessingAttachingBeanPostProcessor() {
-        nodeProcessors = Collections.emptyList();
+
+    /**
+     * Constructor.
+     *
+     * @param processors auto-wired processors to install
+     */
+    @Autowired
+    public NodeProcessingAttachingBeanPostProcessor(
+            @Nullable @NonnullElements final Collection<MetadataNodeProcessor> processors) {
+        if (processors != null) {
+            nodeProcessors = List.copyOf(processors);
+        } else {
+            nodeProcessors = Collections.emptyList();
+        }
     }
     
     /**
-     * Set the {@link MetadataNodeProcessor} instances to auto-attach.
+     * Set the {@link MetadataNodeProcessor} instances to auto-attach instead of the auto-wired set.
      * 
      * @param processors processors to auto-attach
      * 
@@ -65,9 +78,8 @@ public class NodeProcessingAttachingBeanPostProcessor implements BeanPostProcess
      */
     public void setNodeProcessors(@Nullable @NonnullElements final Collection<MetadataNodeProcessor> processors) {
         if (processors != null) {
+            // Replace auto-wired set.
             nodeProcessors = List.copyOf(processors);
-        } else {
-            nodeProcessors = Collections.emptyList();
         }
     }
 
@@ -79,6 +91,10 @@ public class NodeProcessingAttachingBeanPostProcessor implements BeanPostProcess
     /** {@inheritDoc} */
     @Override public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
         
+        if (nodeProcessors.isEmpty()) {
+            return bean;
+        }
+        
         // Do not attach to beans which just include other ones.
         if (!(bean instanceof MetadataResolver) || bean instanceof ChainingMetadataResolver) {
             return bean;

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


More information about the commits mailing list