[java-opensaml] branch main updated: OSJ-399 - Extend metadata resolution with custom criteria
Scott Cantor
cantor.2 at osu.edu
Tue Dec 12 19:00:26 UTC 2023
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=16c3b357b0ee39a4f874b182c872b78dbdc21427
The following commit(s) were added to refs/heads/main by this push:
new 16c3b357b OSJ-399 - Extend metadata resolution with custom criteria
16c3b357b is described below
commit 16c3b357b0ee39a4f874b182c872b78dbdc21427
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Dec 12 14:00:23 2023 -0500
OSJ-399 - Extend metadata resolution with custom criteria
https://shibboleth.atlassian.net/browse/OSJ-399
---
.../SAMLMetadataLookupParametersContext.java | 46 +++++++++++++++++++++-
.../binding/impl/SAMLMetadataLookupHandler.java | 8 ++++
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMetadataLookupParametersContext.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMetadataLookupParametersContext.java
index c1fd790a3..b701423c8 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMetadataLookupParametersContext.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/common/messaging/context/SAMLMetadataLookupParametersContext.java
@@ -14,11 +14,18 @@
package org.opensaml.saml.common.messaging.context;
+import java.util.function.BiConsumer;
+
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.messaging.context.BaseContext;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.metadata.resolver.DetectDuplicateEntityIDs;
+import net.shibboleth.shared.resolver.CriteriaSet;
+import net.shibboleth.shared.resolver.Criterion;
+
/**
* Context for operational parameters that influence the lookup of SAML metadata.
*/
@@ -27,6 +34,9 @@ public class SAMLMetadataLookupParametersContext extends BaseContext {
/** The strategy for duplicate entityID detection. */
@Nullable private DetectDuplicateEntityIDs detectDuplicateEntityIDs;
+ /** An extender hook that can add additional {@link Criterion} objects. */
+ @Nullable private BiConsumer<MessageContext,CriteriaSet> criteriaExtender;
+
/**
* Get the strategy for duplicate entityID detection.
*
@@ -40,9 +50,41 @@ public class SAMLMetadataLookupParametersContext extends BaseContext {
* Set the strategy for duplicate entityID detection.
*
* @param strategy the strategy for duplicate entityID detection
+ *
+ * @return this context
*/
- public void setDetectDuplicateEntityIDs(@Nullable final DetectDuplicateEntityIDs strategy) {
+ @Nonnull public SAMLMetadataLookupParametersContext setDetectDuplicateEntityIDs(
+ @Nullable final DetectDuplicateEntityIDs strategy) {
detectDuplicateEntityIDs = strategy;
+
+ return this;
+ }
+
+ /**
+ * Get a callable hook for extending the {@link CriteriaSet} used for metadata resolution.
+ *
+ * @return callable hook
+ *
+ * @since 5.1.0
+ */
+ @Nullable public BiConsumer<MessageContext,CriteriaSet> getCriteriaExtender() {
+ return criteriaExtender;
+ }
+
+ /**
+ * Set a callable hook for extending the {@link CriteriaSet} used for metadata resolution.
+ *
+ * @param extender callable hook
+ *
+ * @return this context
+ *
+ * @since 5.1.0
+ */
+ @Nonnull public SAMLMetadataLookupParametersContext setCriteriaExtender(
+ @Nullable final BiConsumer<MessageContext,CriteriaSet> extender) {
+ criteriaExtender = extender;
+
+ return this;
}
-}
+}
\ No newline at end of file
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 bb947d828..38ea92165 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
@@ -15,6 +15,7 @@
package org.opensaml.saml.common.binding.impl;
import java.util.Objects;
+import java.util.function.BiConsumer;
import java.util.function.Function;
import javax.annotation.Nonnull;
@@ -249,6 +250,13 @@ public class SAMLMetadataLookupHandler extends AbstractMessageHandler {
final CriteriaSet criteria = new CriteriaSet(entityIdCriterion, protocolCriterion, roleCriterion,
detectDuplicatesCriterion, prcCriterion);
+
+ final BiConsumer<MessageContext,CriteriaSet> hook =
+ lookupParamsContext != null ? lookupParamsContext.getCriteriaExtender() : null;
+ if (hook != null) {
+ hook.accept(messageContext, criteria);
+ }
+
return criteria;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list