[java-plugin-shibd] branch main updated: Add name-based indexing into DDF lists.

Codeberg noreply at shibboleth.net
Wed Nov 11 19:30:54 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/8c05a100d6ae32f1f01b93cbe939a2f34ed86527

The following commit(s) were added to refs/heads/main by this push:
     new 8c05a10  Add name-based indexing into DDF lists.
8c05a10 is described below

commit 8c05a100d6ae32f1f01b93cbe939a2f34ed86527
Author: Scott Cantor <scott at restingparrotsoftware.com>
AuthorDate: Wed Nov 11 14:30:33 2026 -0500

    Add name-based indexing into DDF lists.
---
 .../src/main/java/net/shibboleth/sp/ddf/DDF.java      | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java b/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
index 842aa7b..59126a1 100644
--- a/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/ddf/DDF.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -1014,19 +1015,27 @@ public class DDF implements Iterable<DDF> {
         for (int i = 0; i < tokens.length;) {
             if (tokens[i].startsWith("[") && tokens[i].endsWith("]")) {
                 // Attempt to access a list entry via [n] notation and advance the path.
+                final String indexString = tokens[i].substring(1, tokens[i].length() - 1);
                 int index;
                 try {
-                    index = Integer.valueOf(tokens[i].substring(1, tokens[i].length() - 1));
+                    index = Integer.valueOf(indexString);
                 } catch(final NumberFormatException e) {
-                    index = 0;
+                    index = -1;
                 }
                 if (current.islist()) {
                     assert current.value instanceof List;
                     final List<DDF> currentValue = (List<DDF>) current.value;
-                    if (index < currentValue.size()) {
-                        current = currentValue.get(index);
+                    if (index >= 0) {
+                        if (index < currentValue.size()) {
+                            current = currentValue.get(index);
+                        } else {
+                            return new DDF();
+                        }
                     } else {
-                        return new DDF();
+                        final Optional<DDF> match = currentValue.stream()
+                                .filter(obj -> { return indexString.equals(obj.name()); })
+                                .findFirst();
+                        return match.orElse(new DDF());
                     }
                 } else {
                     return new DDF();

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


More information about the commits mailing list