[java-plugin-shibd] branch main updated: JSHIBD-18 - Automate population of flows, profiles, etc.

Codeberg noreply at shibboleth.net
Thu Jan 15 20:06:13 UTC 2026


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

codeberg pushed a commit to branch main
in repository java-plugin-shibd.

View the commit online:
https://codeberg.org/Shibboleth/java-plugin-shibd/commit/1f9377ee4f4b0e7b311e18585d998740305651b3

The following commit(s) were added to refs/heads/main by this push:
     new 1f9377e  JSHIBD-18 - Automate population of flows, profiles, etc.
1f9377e is described below

commit 1f9377ee4f4b0e7b311e18585d998740305651b3
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 15 15:06:03 2026 -0500

    JSHIBD-18 - Automate population of flows, profiles, etc.
    
    https://shibboleth.atlassian.net/browse/JSHIBD-18
    
    Added automatic injecting of profile configurations.
---
 .../net/shibboleth/idp/module/conf/sp/agents.xml   |  39 +++----
 .../shibboleth/idp/module/conf/sp/sp.properties    |   2 +
 .../net/shibboleth/sp/conf/agents-system.xml       |  20 +++-
 .../idp/module/conf/sp/agents-inheritance.xml      |  40 +++----
 .../net/shibboleth/idp/module/conf/sp/agents.xml   |  39 +++----
 .../shibboleth/sp/BasicProtocolSupportService.java | 120 +++++++++++++++++----
 .../net/shibboleth/sp/ProtocolSupportService.java  |  38 ++++++-
 .../sp/impl/ProfileConfigurationManager.java       |  80 ++++++++++++++
 8 files changed, 295 insertions(+), 83 deletions(-)

diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
index 35a7f3f..ee7fd9d 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/agents.xml
@@ -26,24 +26,6 @@
     <bean p:id="localhost" parent="shibboleth.sp.Agent" />
 
 
-    <!-- ============ Profile defaults ============ -->
-    
-    <!-- Used for all Applications by default to provide a baseline for profile settings. -->
-
-    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
-    <!--
-    Unverified RP configuration, defaults to no support for any profiles.
-    
-    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the identity and
-    legitimacy of an authenticating system. Some profiles may simply be designed to operate this way.
-    -->
-    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
     <!-- ============ RelyingParty Overrides ============ -->
     
     <!--
@@ -56,4 +38,25 @@
         <!-- Your RelyingParty overrides here. -->
     </util:list>
 
+
+    <!-- ============ Overridden Profile Configuration Defaults ============ -->
+    
+    <!--
+    The Hub auto-enables all profiles supplied by any plugins installed for you.
+    Uncommenting and defining these lists will override the default sets and apply them to
+    every Agent/Application for you, if you do not also override the individual properties.        
+
+    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the
+    identity and legitimacy of an authenticating system. Some profiles are designed to operate
+    this way, usually to expose public information about the system.
+    -->
+    
+    <!--
+    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
+    </util:list>
+
+    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
+    </util:list>
+    -->
+
 </beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
index 7e5f1ab..492d79d 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/idp/module/conf/sp/sp.properties
@@ -9,6 +9,8 @@ sp.issuer = https://sp.example.org
 #sp.service.agents.resources = shibboleth.sp.AgentResolverResources
 #sp.service.agents.failFast = false
 sp.service.agents.checkInterval = PT5M
+# Set to true for defaulted profile configs to be metadata-driven/aware
+#sp.service.agents.useMetadataDrivenProfiles = false
 
 # General SP cookie properties
 #sp.cookie.secure = true
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
index 30c8b1b..e344528 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/agents-system.xml
@@ -19,7 +19,17 @@
     <bean id="shibboleth.sp.AgentResolver" class="net.shibboleth.sp.impl.DefaultAgentResolver" />
 
     <!-- Exposes auto-wired protocol support information from protocol plugins. -->
-    <bean id="shibboleth.sp.ProtocolSupportServiceManager" class="net.shibboleth.sp.impl.ProtocolSupportServiceManager" />
+    <bean id="ProtocolSupportServiceManager" class="net.shibboleth.sp.impl.ProtocolSupportServiceManager" />
+
+    <!-- Capture point for plugin-supplied profile configurations to default in if not specified. -->
+    <bean id="VerifiedProfileConfigurations" class="net.shibboleth.sp.impl.ProfileConfigurationManager"
+        c:manager-ref="ProtocolSupportServiceManager"
+        c:verified="true"
+        c:metadataDriven="%{sp.service.agents.useMetadataDrivenProfiles:false}" />
+    <bean id="UnverifiedProfileConfigurations" class="net.shibboleth.sp.impl.ProfileConfigurationManager"
+        c:manager-ref="ProtocolSupportServiceManager"
+        c:verified="false"
+        c:metadataDriven="%{sp.service.agents.useMetadataDrivenProfiles:false}" />
 
     <!-- Parent beans for Agents and Applications. -->
 
@@ -39,7 +49,7 @@
         p:postLimit="%{sp.postData.limit:1048576}" />
 
     <bean id="shibboleth.sp.Application.NoInheritance" class="net.shibboleth.sp.impl.BasicApplication" abstract="true"
-        c:_0-ref="shibboleth.sp.ProtocolSupportServiceManager"
+        c:_0-ref="ProtocolSupportServiceManager"
         p:allowInheritance="false"
         p:metricName="net.shibboleth.sp.relyingparty.configurations"
         p:authenticatingAuthority="%{sp.defaultAuthority:}"
@@ -50,7 +60,7 @@
         p:issuer="#{'%{sp.issuer:}'.trim()}"
         p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
         p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.sp.DefaultSecurityConfiguration}'.trim()}"
-        p:profileConfigurations-ref="shibboleth.sp.DefaultProfileConfigurations"
+        p:profileConfigurations="#{getObject('shibboleth.sp.DefaultProfileConfigurations') ?: getObject('VerifiedProfileConfigurations')}"
         p:unverifiedConfiguration-ref="DefaultUnverifiedRelyingPartyConfiguration"
         p:relyingPartyConfigurations-ref="shibboleth.sp.RelyingPartyOverrides"
         p:discoveryServiceLookupStrategy="#{getObject('%{sp.discoveryURLFunction:DefaultDiscoveryServiceStrategy}'.trim())}"
@@ -77,10 +87,10 @@
         p:issuer="#{'%{sp.issuer:}'.trim()}"
         p:detailedErrorsPredicate="%{sp.errors.detailed:false}"
         p:securityConfiguration-ref="#{'%{sp.security.config:shibboleth.sp.DefaultSecurityConfiguration}'.trim()}"
-        p:profileConfigurations-ref="shibboleth.sp.DefaultProfileConfigurations" />
+        p:profileConfigurations="#{getObject('shibboleth.sp.DefaultProfileConfigurations') ?: getObject('VerifiedProfileConfigurations')}" />
 
     <bean id="DefaultUnverifiedRelyingPartyConfiguration" parent="RelyingParty"
-        p:profileConfigurations-ref="shibboleth.sp.UnverifiedProfileConfigurations" />
+        p:profileConfigurations="#{getObject('shibboleth.sp.UnverifiedProfileConfigurations') ?: getObject('UnverifiedProfileConfigurations')}" />
 
     <!-- Parent bean for RelyingParty overrides based on activation by name(s). -->
     <bean id="RelyingPartyByName" abstract="true" parent="RelyingParty"
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml
index 456ecda..d6c66b4 100644
--- a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml
+++ b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents-inheritance.xml
@@ -43,26 +43,7 @@
         </property>
     </bean>
     
-
-    <!-- ============ Profile defaults ============ -->
-    
-    <!-- Used for all applications by default to provide a baseline for profile settings. -->
-
-    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
-    <!--
-    Unverified RP configuration, defaults to no support for any profiles.
     
-    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the identity and
-    legitimacy of an authenticating system. Some profiles may simply be designed to operate this way.
-    -->
-    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
-
     <!-- ============ RelyingParty Overrides ============ -->
     
     <!--
@@ -77,5 +58,26 @@
             p:issuer="https://example.org/override3"/>
     
     </util:list>
+    
+
+    <!-- ============ Overridden Profile Configuration Defaults ============ -->
+    
+    <!--
+    The Hub auto-enables all profiles supplied by any plugins installed for you.
+    Uncommenting and defining these lists will override the default sets and apply them to
+    every Agent/Application for you, if you do not also override the individual properties.        
+
+    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the
+    identity and legitimacy of an authenticating system. Some profiles are designed to operate
+    this way, usually to expose public information about the system.
+    -->
+    
+    <!--
+    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
+    </util:list>
+
+    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
+    </util:list>
+    -->
 
 </beans>
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
index c77aaa8..2d22c0b 100644
--- a/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
+++ b/sp-conf-impl/src/test/resources/net/shibboleth/idp/module/conf/sp/agents.xml
@@ -27,24 +27,6 @@
         p:credentials="#{ {null : 'foo'} }" />
     
 
-    <!-- ============ Profile defaults ============ -->
-    
-    <!-- Used for all applications by default to provide a baseline for profile settings. -->
-
-    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
-    <!--
-    Unverified RP configuration, defaults to no support for any profiles.
-    
-    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the identity and
-    legitimacy of an authenticating system. Some profiles may simply be designed to operate this way.
-    -->
-    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
-        <!-- Your profiles here. -->
-    </util:list>
-
     <!-- ============ RelyingParty Overrides ============ -->
     
     <!--
@@ -57,4 +39,25 @@
         <!-- Your RelyingParty overrides here. -->
     </util:list>
 
+
+    <!-- ============ Overridden Profile Configuration Defaults ============ -->
+    
+    <!--
+    The Hub auto-enables all profiles supplied by any plugins installed for you.
+    Uncommenting and defining these lists will override the default sets and apply them to
+    every Agent/Application for you, if you do not also override the individual properties.        
+
+    "Unverified" typically means the Hub has no metadata, or equivalent way of assuring the
+    identity and legitimacy of an authenticating system. Some profiles are designed to operate
+    this way, usually to expose public information about the system.
+    -->
+    
+    <!--
+    <util:list id="shibboleth.sp.DefaultProfileConfigurations">
+    </util:list>
+
+    <util:list id="shibboleth.sp.UnverifiedProfileConfigurations">
+    </util:list>
+    -->
+
 </beans>
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/BasicProtocolSupportService.java b/sp-server-api/src/main/java/net/shibboleth/sp/BasicProtocolSupportService.java
index 8077a36..29e7e98 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/BasicProtocolSupportService.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/BasicProtocolSupportService.java
@@ -14,6 +14,7 @@
 
 package net.shibboleth.sp;
 
+import java.util.Collection;
 import java.util.List;
 
 import javax.annotation.Nonnull;
@@ -21,6 +22,9 @@ import javax.annotation.Nullable;
 
 import org.springframework.core.Ordered;
 
+import net.shibboleth.profile.config.ProfileConfiguration;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
 import net.shibboleth.shared.primitive.StringSupport;
@@ -41,10 +45,26 @@ public class BasicProtocolSupportService extends AbstractIdentifiableInitializab
     /** Consumer flow IDs. */
     @Nonnull private List<String> consumers;
     
+    /** Non-metadata-driven verified configurations. */
+    @Nonnull private Collection<ProfileConfiguration> profileConfigurations;
+
+    /** Metadata-driven verified configurations. */
+    @Nonnull private Collection<ProfileConfiguration> metadataDrivenProfileConfigurations;
+
+    /** Non-metadata-driven unverified configurations. */
+    @Nonnull private Collection<ProfileConfiguration> unverifiedProfileConfigurations;
+
+    /** Metadata-driven unverified configurations. */
+    @Nonnull private Collection<ProfileConfiguration> metadataDrivenUnverifiedProfileConfigurations;
+    
     /** Constructor. */
     public BasicProtocolSupportService() {
         initiators = CollectionSupport.emptyList();
         consumers = CollectionSupport.emptyList();
+        profileConfigurations = CollectionSupport.emptySet();
+        metadataDrivenProfileConfigurations = CollectionSupport.emptySet();
+        unverifiedProfileConfigurations = CollectionSupport.emptySet();
+        metadataDrivenUnverifiedProfileConfigurations = CollectionSupport.emptySet();
     }
     
     /** {@inheritDoc} */
@@ -58,18 +78,13 @@ public class BasicProtocolSupportService extends AbstractIdentifiableInitializab
      * @param priority priority value
      */
     public void setOrder(final int priority) {
+        checkSetterPreconditions();
+        
         order = priority;
     }
     
-    /**
-     * Get a default-ordered list of session initiator flows supported by this protocol plugin.
-     *
-     * <p>The default order should reflect what "most" deployers would expect to use when adding
-     * support for this plugin to their system.</p>
-     *  
-     * @return ordered list of unprefixed flow IDs
-     */
-    @Nonnull public List<String> getSessionInitiators() {
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public List<String> getSessionInitiators() {
         return initiators;
     }
     
@@ -84,15 +99,8 @@ public class BasicProtocolSupportService extends AbstractIdentifiableInitializab
         initiators = CollectionSupport.copyToList(StringSupport.normalizeStringCollection(flows));
     }
 
-    /**
-     * Get a default-ordered list of token consumer flows supported by this protocol plugin.
-     *  
-     * <p>The default order should reflect what "most" deployers would expect to use when adding
-     * support for this plugin to their system.</p>
-     * 
-     * @return ordered list of unprefixed flow IDs
-     */
-    @Nonnull public List<String> getTokenConsumers() {
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public List<String> getTokenConsumers() {
         return consumers;
     }
     
@@ -107,4 +115,80 @@ public class BasicProtocolSupportService extends AbstractIdentifiableInitializab
         consumers = CollectionSupport.copyToList(StringSupport.normalizeStringCollection(flows));
     }
 
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public Collection<ProfileConfiguration> getDefaultProfileConfigurations(
+            boolean metadataDriven) {
+        return metadataDriven ? metadataDrivenProfileConfigurations : profileConfigurations;
+    }
+
+    /**
+     * Sets the collection of available non-metadata-driven {@link ProfileConfiguration} objects to install
+     * for "verified" use.
+     * 
+     * @param configs profile configurations
+     */
+    public void setDefaultProfileConfigurations(@Nullable final Collection<ProfileConfiguration> configs) {
+        checkSetterPreconditions();
+        
+        if (configs != null) {
+            profileConfigurations = CollectionSupport.copyToSet(configs);
+        } else {
+            profileConfigurations = CollectionSupport.emptySet();
+        }
+    }
+    
+    /**
+     * Sets the collection of available metadata-driven {@link ProfileConfiguration} objects to install
+     * for "verified" use.
+     * 
+     * @param configs profile configurations
+     */
+    public void setMetadataDrivenDefaultProfileConfigurations(@Nullable final Collection<ProfileConfiguration> configs) {
+        checkSetterPreconditions();
+        
+        if (configs != null) {
+            metadataDrivenProfileConfigurations = CollectionSupport.copyToSet(configs);
+        } else {
+            metadataDrivenProfileConfigurations = CollectionSupport.emptySet();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Nonnull @Unmodifiable @NotLive public Collection<ProfileConfiguration> getUnverifiedProfileConfigurations(
+            boolean metadataDriven) {
+        return metadataDriven ? metadataDrivenUnverifiedProfileConfigurations : unverifiedProfileConfigurations;
+    }
+
+    /**
+     * Sets the collection of available non-metadata-driven {@link ProfileConfiguration} objects to install
+     * for "unverified" use.
+     * 
+     * @param configs profile configurations
+     */
+    public void setUnverifiedProfileConfigurations(@Nullable final Collection<ProfileConfiguration> configs) {
+        checkSetterPreconditions();
+        
+        if (configs != null) {
+            unverifiedProfileConfigurations = CollectionSupport.copyToSet(configs);
+        } else {
+            unverifiedProfileConfigurations = CollectionSupport.emptySet();
+        }
+    }
+    
+    /**
+     * Sets the collection of available metadata-driven {@link ProfileConfiguration} objects to install
+     * for "unverified" use.
+     * 
+     * @param configs profile configurations
+     */
+    public void setMetadataDrivenUnverifiedDefaultProfileConfigurations(@Nullable final Collection<ProfileConfiguration> configs) {
+        checkSetterPreconditions();
+        
+        if (configs != null) {
+            metadataDrivenUnverifiedProfileConfigurations = CollectionSupport.copyToSet(configs);
+        } else {
+            metadataDrivenUnverifiedProfileConfigurations = CollectionSupport.emptySet();
+        }
+    }
+
 }
\ No newline at end of file
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/ProtocolSupportService.java b/sp-server-api/src/main/java/net/shibboleth/sp/ProtocolSupportService.java
index 729eb15..0b8873b 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/ProtocolSupportService.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/ProtocolSupportService.java
@@ -14,10 +14,14 @@
 
 package net.shibboleth.sp;
 
+import java.util.Collection;
 import java.util.List;
 
 import javax.annotation.Nonnull;
 
+import net.shibboleth.profile.config.ProfileConfiguration;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
 import net.shibboleth.shared.component.IdentifiedComponent;
 
 /**
@@ -32,23 +36,47 @@ import net.shibboleth.shared.component.IdentifiedComponent;
 public interface ProtocolSupportService extends IdentifiedComponent {
 
     /**
-     * Get a default-ordered list of session initiator flows supported by this protocol plugin.
+     * Gets a default-ordered list of session initiator flows supported by this protocol plugin.
      *
      * <p>The default order should reflect what "most" deployers would expect to use when adding
      * support for this plugin to their system.</p>
      *  
      * @return ordered list of unprefixed flow IDs
      */
-    @Nonnull List<String> getSessionInitiators();
+    @Nonnull @Unmodifiable @NotLive List<String> getSessionInitiators();
 
     /**
-     * Get a default-ordered list of token consumer flows supported by this protocol plugin.
+     * Gets a default-ordered list of token consumer flows supported by this protocol plugin.
      *  
      * <p>The default order should reflect what "most" deployers would expect to use when adding
      * support for this plugin to their system.</p>
      * 
      * @return ordered list of unprefixed flow IDs
      */
-    @Nonnull List<String> getTokenConsumers();
-    
+    @Nonnull @Unmodifiable @NotLive List<String> getTokenConsumers();
+
+    /**
+     * Gets the collection of default {@link ProfileConfiguration} objects supplied by this protocol plugin.
+     * 
+     * <p>This collectuon should include only profiles intended for "verified" use by default.</p>
+     * 
+     * @param metadataDriven true iff the metadata-driven variant of these objects should be returned
+     *  
+     * @return the relevant available profile configurations
+     */
+    @Nonnull @Unmodifiable @NotLive Collection<ProfileConfiguration> getDefaultProfileConfigurations(
+            final boolean metadataDriven);
+
+    /**
+     * Gets the collection of default {@link ProfileConfiguration} objects supplied by this protocol plugin.
+     * 
+     * <p>This collectuon should include only profiles intended for "unverified" use by default.</p>
+     * 
+     * @param metadataDriven true iff the metadata-driven variant of these objects should be returned
+     *  
+     * @return the relevant available profile configurations
+     */
+    @Nonnull @Unmodifiable @NotLive Collection<ProfileConfiguration> getUnverifiedProfileConfigurations(
+            final boolean metadataDriven);
+
 }
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/impl/ProfileConfigurationManager.java b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/ProfileConfigurationManager.java
new file mode 100644
index 0000000..679b4a2
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/impl/ProfileConfigurationManager.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed 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.sp.impl;
+
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import net.shibboleth.profile.config.ProfileConfiguration;
+import net.shibboleth.shared.annotation.ParameterName;
+import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.sp.Application;
+import net.shibboleth.sp.ProtocolSupportService;
+
+/**
+ * A wrapper class for collecting plugin-supplied {@link ProfileConfiguration} beans
+ * and using them as an implicit defaults to install into {@link Application} beans in place
+ * of a deployer-managed manual list.
+ * 
+ * <p>The constructor tailors the set of profiles managed and exposed based on whether they
+ * should be verified or unverified profiles and standard or metadata-drive variants.</p>
+ */
+public class ProfileConfigurationManager extends AbstractCollection<ProfileConfiguration> {
+
+    /** Underlying collection. */
+    @Nonnull private final Collection<ProfileConfiguration> profileConfigurations;
+    
+    /**
+     * Constructor.
+     *
+     * @param manager           injected plugin-supplied source of default {@link ProfileConfiguration} instances
+     * @param verified          toggles between exposing verified or unverified profiles
+     * @param metadataDriven    flag controlling which profile configurations to expose
+     */
+    public ProfileConfigurationManager(
+            @ParameterName(name="manager") @Nullable final ProtocolSupportServiceManager manager,
+            @ParameterName(name="verified") final boolean verified,
+            @ParameterName(name="metadataDriven") final boolean metadataDriven) {
+        
+        if (manager != null ) {
+            profileConfigurations = new HashSet<>();
+            for (final ProtocolSupportService service : manager.getComponents()) {
+                profileConfigurations.addAll(
+                        verified ?  service.getDefaultProfileConfigurations(metadataDriven) :
+                            service.getUnverifiedProfileConfigurations(metadataDriven));
+            }
+        } else {
+            profileConfigurations = CollectionSupport.emptySet();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Iterator<ProfileConfiguration> iterator() {
+        return profileConfigurations.iterator();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int size() {
+        return profileConfigurations.size();
+    }
+    
+}
\ 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