[java-oidfed-common] 02/02: Validate metadata policies for all entity types before merging

Codeberg noreply at shibboleth.net
Fri Nov 13 07:36:41 UTC 2026


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

codeberg pushed a commit to branch main
in repository java-oidfed-common.

View the commit online:
https://codeberg.org/Shibboleth/java-oidfed-common/commit/687657e88460673a12c7a947705f06300a43d264

commit 687657e88460673a12c7a947705f06300a43d264
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Nov 13 09:35:28 2026 +0200

    Validate metadata policies for all entity types before merging
    
    - Fulfills better the specification section 6.1.4 to only contain allowed operator combinations
    - Update XML-wirings accordingly
---
 .../oidfed/resolve-entity/resolve-entity-beans.xml |  8 ++++++-
 .../resolve-trust-chains-beans.xml                 |  5 +++++
 ...ultTrustChainMetadataPolicyMergingStrategy.java | 26 +++++++++++++++++++++-
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
index 9178f4e..3fd7f47 100644
--- a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
+++ b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-entity/resolve-entity-beans.xml
@@ -148,7 +148,13 @@
     <bean id="FlowDefaultTrustChainMetadataPolicyMergingStrategy" 
         class="net.shibboleth.oidfed.profile.navigate.DefaultTrustChainMetadataPolicyMergingStrategy"
         p:metadataPolicyMergingStrategy-ref="#{'%{idp.oidfed.resolveEntity.MetadataPolicyMergingStrategy:FlowDefaultMetadataPolicyMergingStrategy}'.trim()}"
-        p:localMetadataPolicyStrategy-ref="#{'%{idp.oidfed.resolveEntity.LocalMetadataPolicyStrategy:FlowDefaultLocalMetadataPolicyStrategy}'.trim()}"/>
+        p:localMetadataPolicyStrategy-ref="#{'%{idp.oidfed.resolveEntity.LocalMetadataPolicyStrategy:FlowDefaultLocalMetadataPolicyStrategy}'.trim()}">
+        <property name="metadataPolicyValidationStrategy">
+            <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyValidator"
+                p:failureOnUnknownOperators="false"
+                p:metadataPolicyOperators-ref="#{'%{idp.oidfed.resolveEntity.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
+        </property>
+    </bean>
 
     <bean id="FlowDefaultMetadataPolicyMergingStrategy"
         class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyMergingStrategy"
diff --git a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
index d998d2b..e2dae97 100644
--- a/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
+++ b/oidfed-common-conf-impl/src/main/resources/META-INF/net/shibboleth/idp/flows/oidfed/resolve-trust-chains/resolve-trust-chains-beans.xml
@@ -58,6 +58,11 @@
             <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyMergingStrategy"
                 p:metadataPolicyOperators-ref="#{'%{idp.oidfed.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
         </property>
+        <property name="metadataPolicyValidationStrategy">
+            <bean class="net.shibboleth.oidc.metadata.policy.impl.DefaultMetadataPolicyValidator"
+                p:failureOnUnknownOperators="false"
+                p:metadataPolicyOperators-ref="#{'%{idp.oidfed.MetadataPolicyOperators:shibboleth.oidfed.StandardMetadataPolicyOperators}'.trim()}"/>
+        </property>
     </bean>
 
     <bean id="shibboleth.oidfed.trust-chain-resolver.DefaultLocalMetadataPolicyStrategy"
diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/navigate/DefaultTrustChainMetadataPolicyMergingStrategy.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/navigate/DefaultTrustChainMetadataPolicyMergingStrategy.java
index 8e56d23..ca9794f 100644
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/navigate/DefaultTrustChainMetadataPolicyMergingStrategy.java
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/navigate/DefaultTrustChainMetadataPolicyMergingStrategy.java
@@ -19,6 +19,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.function.BiFunction;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -52,6 +53,9 @@ public class DefaultTrustChainMetadataPolicyMergingStrategy extends AbstractIden
     @NonnullAfterInit private Function<List<EntityStatement<?>>, Map<String, MetadataPolicy>>
         localMetadataPolicyStrategy;
 
+    /** The strategy used to validate a metadata policy for an entity type. */
+    @NonnullAfterInit private Predicate<Map<String, MetadataPolicy>> metadataPolicyValidationStrategy;
+
     /**
      * Set the strategy used for merging two metadata policies.
      * 
@@ -76,6 +80,17 @@ public class DefaultTrustChainMetadataPolicyMergingStrategy extends AbstractIden
                 "Local metadata policy strategy cannot be null");
     }
 
+    /**
+     * Set the strategy used to validate a metadata policy for an entity type.
+     * 
+     * @param strategy What to set.
+     */
+    public void setMetadataPolicyValidationStrategy(@Nonnull final Predicate<Map<String, MetadataPolicy>> strategy) {
+        checkSetterPreconditions();
+        metadataPolicyValidationStrategy =
+                Constraint.isNotNull(strategy, "Metadata policy validation strategy cannot be null");
+    }
+
     /** {@inheritDoc} */
     protected void doInitialize() throws ComponentInitializationException {
         super.doInitialize();
@@ -86,6 +101,9 @@ public class DefaultTrustChainMetadataPolicyMergingStrategy extends AbstractIden
         if (localMetadataPolicyStrategy == null) {
             throw new ComponentInitializationException("Local metadata policy strategy cannot be null");
         }
+        if (metadataPolicyValidationStrategy == null) {
+            throw new ComponentInitializationException("Metadata policy validation strategy cannot be null");
+        }
     }
 
     /** {@inheritDoc} */
@@ -104,7 +122,13 @@ public class DefaultTrustChainMetadataPolicyMergingStrategy extends AbstractIden
                 if (policy == null || policy.isEmpty()) {
                     continue;
                 }
-
+                for (final String type : policy.keySet()) {
+                    if (!metadataPolicyValidationStrategy.test(policy.get(type))) {
+                        throw new ConstraintViolationException("Metadata policy for entity type " + type
+                                + " is invalid in the subordinate statement issued by " + ssp.getIssuer() + " for "
+                                + ssp.getSubject());
+                    }
+                }
                 if (StringSupport.trimOrNull(entityType) != null) {
                     try {
                         assert entityType != null;

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


More information about the commits mailing list