[java-opensaml] branch main updated: OSJ-363 - Add activationCondition support to MetadataResolvers

Scott Cantor cantor.2 at osu.edu
Wed Oct 19 17:31:26 UTC 2022


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

scantor pushed a commit to branch main
in repository java-opensaml.

View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=79052069e4297a1b3ee1c9abb06180591bad16a4

The following commit(s) were added to refs/heads/main by this push:
     new 79052069e OSJ-363 - Add activationCondition support to MetadataResolvers
79052069e is described below

commit 79052069e4297a1b3ee1c9abb06180591bad16a4
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 19 13:31:23 2022 -0400

    OSJ-363 - Add activationCondition support to MetadataResolvers
    
    https://shibboleth.atlassian.net/browse/OSJ-363
    
    Attach PRC criterion when applicable.
---
 .../binding/impl/SAMLMetadataLookupHandler.java    | 42 ++++++++++++++++++++--
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLMetadataLookupHandler.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLMetadataLookupHandler.java
index 7a511db15..f6e20a806 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLMetadataLookupHandler.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/common/binding/impl/SAMLMetadataLookupHandler.java
@@ -26,8 +26,11 @@ import javax.xml.namespace.QName;
 
 import org.opensaml.core.criterion.EntityIdCriterion;
 import org.opensaml.messaging.context.MessageContext;
+import org.opensaml.messaging.context.navigate.ParentContextLookup;
 import org.opensaml.messaging.handler.AbstractMessageHandler;
 import org.opensaml.messaging.handler.MessageHandlerException;
+import org.opensaml.profile.context.ProfileRequestContext;
+import org.opensaml.profile.criterion.ProfileRequestContextCriterion;
 import org.opensaml.saml.common.messaging.context.AbstractSAMLEntityContext;
 import org.opensaml.saml.common.messaging.context.SAMLMetadataContext;
 import org.opensaml.saml.common.messaging.context.SAMLMetadataLookupParametersContext;
@@ -80,10 +83,19 @@ public class SAMLMetadataLookupHandler extends AbstractMessageHandler {
     
     /** The context class representing the SAML entity whose data is to be resolved. 
      * Defaults to: {@link SAMLPeerEntityContext}. */
-    @Nonnull private Class<? extends AbstractSAMLEntityContext> entityContextClass = SAMLPeerEntityContext.class;
+    @Nonnull private Class<? extends AbstractSAMLEntityContext> entityContextClass;
 
     /** Optional strategy for resolving an existing metadata context from which to copy data. */
-    @Nullable private Function<MessageContext, SAMLMetadataContext> copyContextStrategy;
+    @Nullable private Function<MessageContext,SAMLMetadataContext> copyContextStrategy;
+    
+    /** Optional but defaulted strategy for locating a PRC. */
+    @Nullable private Function<MessageContext,ProfileRequestContext> profileRequestContextLookupStrategy;
+    
+    /** Constructor. */
+    public SAMLMetadataLookupHandler() {
+        entityContextClass = SAMLPeerEntityContext.class;
+        profileRequestContextLookupStrategy = new ParentContextLookup<>(ProfileRequestContext.class);
+    }
 
     /**
      * Set the optional strategy for resolving an existing metadata context from which to copy data.
@@ -117,6 +129,22 @@ public class SAMLMetadataLookupHandler extends AbstractMessageHandler {
         metadataResolver = Constraint.isNotNull(resolver, "RoleDescriptorResolver cannot be null");
     }
     
+    /**
+     * Set optional lookup strategy for locating {@link ProfileRequestContext}.
+     * 
+     * <p>Defaults to parent lookup. If set and found, a {@link ProfileRequestContextCriterion} will be included
+     * in the attempt.</p>
+     * 
+     * @param strategy
+     * 
+     * @since 5.0.0
+     */
+    public void setProfileRequestContextLookupStrategy(
+            @Nullable final Function<MessageContext,ProfileRequestContext> strategy) {
+        checkSetterPreconditions();
+        profileRequestContextLookupStrategy = strategy;
+    }
+    
     /** {@inheritDoc} */
     @Override
     protected void doInitialize() throws ComponentInitializationException {
@@ -207,8 +235,16 @@ public class SAMLMetadataLookupHandler extends AbstractMessageHandler {
                     new DetectDuplicateEntityIDsCriterion(lookupParamsContext.getDetectDuplicateEntityIDs()); 
         }
         
+        ProfileRequestContextCriterion prcCriterion = null;
+        if (profileRequestContextLookupStrategy != null) {
+            final ProfileRequestContext prc = profileRequestContextLookupStrategy.apply(messageContext);
+            if (prc != null) {
+                prcCriterion = new ProfileRequestContextCriterion(prc);
+            }
+        }
+        
         final CriteriaSet criteria = new CriteriaSet(entityIdCriterion, protocolCriterion, roleCriterion,
-                detectDuplicatesCriterion);
+                detectDuplicatesCriterion, prcCriterion);
         return criteria;
     }
 

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


More information about the commits mailing list