[java-oidfed-common] 01/02: Return InvalidMetadata when policy-enforced metadata is not valid

Codeberg noreply at shibboleth.net
Fri Nov 13 07:36:40 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/1261baabda877afab968242cc48d0d01f24ee602

commit 1261baabda877afab968242cc48d0d01f24ee602
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Fri Nov 13 08:14:43 2026 +0200

    Return InvalidMetadata when policy-enforced metadata is not valid
    
    - Improve logging
    - Drop the unnecessary use of Nimbus JSONObject
---
 .../profile/impl/AbstractTrustChainResolutionAction.java      | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
index a501e10..d58103e 100644
--- a/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
+++ b/oidfed-common-impl/src/main/java/net/shibboleth/oidfed/profile/impl/AbstractTrustChainResolutionAction.java
@@ -31,7 +31,6 @@ import org.opensaml.profile.context.ProfileRequestContext;
 import org.opensaml.profile.context.navigate.InboundMessageContextLookup;
 import org.slf4j.Logger;
 
-import net.minidev.json.JSONObject;
 import net.shibboleth.idp.profile.AbstractProfileAction;
 import net.shibboleth.oidc.metadata.policy.MetadataPolicy;
 import net.shibboleth.oidc.metadata.policy.impl.MetadataPolicyHelper;
@@ -304,7 +303,7 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
                     return OidFederationEventIds.INVALID_METADATA_POLICY;
                 }
 
-                final JSONObject requestMetadata = new JSONObject(metadata.get(entityType));
+                final Map<String, Object> requestMetadata = new HashMap<>(metadata.get(entityType));
                 for (final String claim : mergedPolicies.keySet()) {
                     assert claim != null;
                     final MetadataPolicy policy = mergedPolicies.get(claim);
@@ -318,7 +317,8 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
                             requestMetadata.remove(claim);
                         }
                     } catch (final ConstraintViolationException e) {
-                        log.warn("{} The requested metadata is not compliant with the policy", getLogPrefix());
+                        log.warn("{} The requested metadata is not compliant for {} with entity type {}: {}",
+                                getLogPrefix(), chain.get(0).getSubject(), entityType, e.getMessage());
                         return OidFederationEventIds.INVALID_METADATA_AGAINST_POLICY;
                     }
                 }
@@ -326,10 +326,11 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
                 log.debug("{} The requested metadata is compliant with the policy", getLogPrefix());
                 if (metadataValidationCondition.test(entityType, requestMetadata)) {
                     verifiedMetadata.put(entityType, requestMetadata);
-                    log.debug("{} Policy-enforced metadata {}", getLogPrefix(), requestMetadata.toJSONString());
+                    log.debug("{} Policy-enforced metadata passed validation {}", getLogPrefix(), requestMetadata);
                 } else {
                     log.warn("{} Metadata validation failed for {} for entity type {}", getLogPrefix(),
                             chain.get(0).getSubject(), entityType);
+                    return OidFederationEventIds.INVALID_METADATA;
                 }
             }
             policyCompliantChains.add(new VerifiedTrustChain(chain, new MetadataImpl(verifiedMetadata)));
@@ -351,7 +352,7 @@ public class AbstractTrustChainResolutionAction extends AbstractProfileAction {
     @Nullable protected Object enforceValue(@Nonnull final String claim, @Nullable final Object value,
             @Nullable final MetadataPolicy policy) throws ConstraintViolationException {
         log.debug("{} Claim {} set in policy included in the request: {}", getLogPrefix(), claim,
-                value == null);
+                value != null);
         final Object enforcerInput = MetadataPolicyHelper.transformSpaceSeparatedStringIntoList(
                 arraysAsSpaceSeparatedList, claim, value);
 

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


More information about the commits mailing list