[java-plugin-shibd] branch main updated: Add type filtering to resolver base class.

Codeberg noreply at shibboleth.net
Tue Jul 28 23:47:05 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/0d3ffe4edd795b04be9b57875a309b26414bc0f2

The following commit(s) were added to refs/heads/main by this push:
     new 0d3ffe4  Add type filtering to resolver base class.
0d3ffe4 is described below

commit 0d3ffe4edd795b04be9b57875a309b26414bc0f2
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Tue Jul 28 19:46:50 2026 -0400

    Add type filtering to resolver base class.
---
 .../AbstractOrderedCredentialResolver.java         | 40 +++++++++++++++++-----
 1 file changed, 31 insertions(+), 9 deletions(-)

diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/credential/AbstractOrderedCredentialResolver.java b/sp-server-api/src/main/java/net/shibboleth/sp/credential/AbstractOrderedCredentialResolver.java
index 96cf8c4..249daad 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/credential/AbstractOrderedCredentialResolver.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/credential/AbstractOrderedCredentialResolver.java
@@ -33,8 +33,10 @@ import com.google.common.collect.Iterables;
 import net.shibboleth.shared.collection.CollectionSupport;
 import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
 import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.logic.PredicateSupport;
 import net.shibboleth.shared.primitive.LoggerFactory;
 import net.shibboleth.shared.primitive.StringSupport;
+import net.shibboleth.shared.resolver.ClassCriterion;
 import net.shibboleth.shared.resolver.CriteriaSet;
 import net.shibboleth.shared.resolver.ResolverException;
 
@@ -131,20 +133,40 @@ public abstract class AbstractOrderedCredentialResolver extends AbstractIdentifi
             return CollectionSupport.emptyList();
         }
         
-        final Iterable<Credential> creds = doResolve(criteria);
+        return filter(doResolve(criteria), criteria);
+    }
+    
+    /**
+     * Filter the supplied credentials by type and/or usage as required.
+     * 
+     * @param creds resolved credentials
+     * @param criteria input criteria
+     * 
+     * @return filtered credentials
+     */
+    @Nonnull private Iterable<Credential> filter(@Nonnull final Iterable<Credential> creds,
+            @Nullable CriteriaSet criteria) {
         
-        if (!filterByUsage) {
-            return creds;
-        }
+        final UsageCriterion usage = criteria != null && filterByUsage ? criteria.get(UsageCriterion.class) : null;
+        final ClassCriterion<?> classCriterion = criteria != null ? criteria.get(ClassCriterion.class) : null;
+
+        final Predicate<Credential> condition;
         
-        final UsageCriterion usage = criteria != null ? criteria.get(UsageCriterion.class) : null;
-        if (usage == null) {
+        if (usage != null && classCriterion != null ) {
+            log.debug("CredentialResolver {}: Filtering results by usage ({}) and type ({})", getId(),
+                    usage.getUsage(), classCriterion.getType());
+            condition = PredicateSupport.and(
+                    classCriterion.getType()::isInstance, new UsageCriterionPredicate(usage.getUsage()));
+        } else if (usage != null) {
+            log.debug("CredentialResolver {}: Filtering results by usage ({})", getId(), usage.getUsage());
+            condition = new UsageCriterionPredicate(usage.getUsage());
+        } else if (classCriterion != null) {
+            log.debug("CredentialResolver {}: Filtering results by type ({})", getId(), classCriterion.getType());
+            condition = classCriterion.getType()::isInstance;
+        } else {
             return creds;
         }
         
-        log.debug("CredentialResolver {}: Filtering results by usage ({})", getId(), usage.getUsage());
-        
-        final UsageCriterionPredicate condition = new UsageCriterionPredicate(usage.getUsage());
         return Iterables.filter(creds, condition::test);
     }
     

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


More information about the commits mailing list