[java-plugin-shibd] branch main updated: Remove pointer type from DDF impl.

Scott Cantor cantor.2 at osu.edu
Thu Jan 16 16:11:57 UTC 2025


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

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

View the commit online:
http://git.shibboleth.net/view/?p=java-plugin-shibd.git;a=commit;h=bad30cfdac3a2436f53c4cc569cfdf27435c2df1

The following commit(s) were added to refs/heads/main by this push:
     new bad30cf  Remove pointer type from DDF impl.
bad30cf is described below

commit bad30cfdac3a2436f53c4cc569cfdf27435c2df1
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Jan 16 11:11:54 2025 -0500

    Remove pointer type from DDF impl.
---
 .../src/main/java/net/shibboleth/sp/ddf/DDF.java   | 78 ++--------------------
 .../test/java/net/shibboleth/sp/ddf/DDFTest.java   | 19 ++----
 .../resources/net/shibboleth/sp/ddf/long-name.ddf  |  2 +-
 .../net/shibboleth/sp/ddf/unsafestring-name.ddf    |  2 +-
 4 files changed, 12 insertions(+), 89 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 3eeb160..f9ed8ca 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
@@ -89,14 +89,11 @@ public class DDF implements Iterable<DDF> {
         /** An ordered list. */
         DDF_LIST(5),
         
-        /** A reference to any object. */
-        DDF_POINTER(6),
-        
         /** A string that cannot be assumed to be UTF-8 (see above docs). */
-        DDF_STRING_UNSAFE(7),
+        DDF_STRING_UNSAFE(6),
         
         /** An integral value of no more than 64-bits. */
-        DDF_LONG(8);
+        DDF_LONG(7);
         
         /** Type value. */
         private final int value;
@@ -159,16 +156,12 @@ public class DDF implements Iterable<DDF> {
                 case 5:
                     type = DDF_LIST;
                     break;
-
-                case 6:
-                    type = DDF_POINTER;
-                    break;
                     
-                case 7:
+                case 6:
                     type = DDF_STRING_UNSAFE;
                     break;
                 
-                case 8:
+                case 7:
                     type = DDF_LONG;
                     break;
                     
@@ -269,19 +262,6 @@ public class DDF implements Iterable<DDF> {
         floating(val);
     }
 
-    /**
-     * Constructor.
-     *
-     * <p>For compatibility, the name is constrained to no more than 255 characters.</p>
-     *
-     * @param n node name
-     * @param val object value
-     */
-    public DDF(@Nullable @NotEmpty final String n, @Nullable final Object val) {
-        this(n);
-        pointer(val);
-    }
-
     /**
      * Destroys a node's content, resets it to a null object and clears its name.
      * 
@@ -473,15 +453,6 @@ public class DDF implements Iterable<DDF> {
         return type == DDFType.DDF_LIST;
     }
 
-    /**
-     * Returns true iff the node is a pointer (i.e., object reference).
-     * 
-     * @return true iff the node is a pointer (i.e., object reference)
-     */
-    public boolean ispointer() {
-        return type == DDFType.DDF_POINTER;
-    }
-
     /**
      * Get the string value of this node.
      * 
@@ -621,16 +592,6 @@ public class DDF implements Iterable<DDF> {
         return null;
     }
 
-    /**
-     * Get the pointer/reference value of this node, which is just an {@link Object}.
-     * 
-     * @return pointer/reference value or null
-     */
-    @Nullable public Object pointer() {
-        return ispointer() ? value : null;
-    }
-
-
     /**
      * Converts this node to an empty type/value.
      * 
@@ -828,20 +789,6 @@ public class DDF implements Iterable<DDF> {
         return this;
     }
 
-    /**
-     * Converts this node to a pointer/reference type.
-     * 
-     * @param val value to inject
-     * 
-     * @return this object
-     */
-    @Nonnull public DDF pointer(@Nullable final Object val) {
-        empty();
-        value = val;
-        type = DDFType.DDF_POINTER;
-        return this;
-    }
-
     /**
      * Adds a node to the end of a struct or list and returns it.
      * 
@@ -1316,19 +1263,6 @@ public class DDF implements Iterable<DDF> {
                 builder.append('}');
                 break;
 
-            case DDF_POINTER:
-                builder.append("Object");
-                if (name != null) {
-                    builder.append(' ').append(name);
-                }
-                builder.append(" = ");
-                if (value != null) {
-                    builder.append(value);
-                } else {
-                    builder.append("null");
-                }
-                break;
-
             default:
                 builder.append("UNKNOWN -- WARNING: ILLEGAL VALUE");
         }
@@ -1357,7 +1291,6 @@ public class DDF implements Iterable<DDF> {
 
             switch (type) {
                 case DDF_EMPTY:
-                case DDF_POINTER:
                     os.write(Integer.toString(DDFType.DDF_EMPTY.getValue()).getBytes(StandardCharsets.UTF_8));
                     os.write('\n');
                     break;
@@ -1509,9 +1442,8 @@ public class DDF implements Iterable<DDF> {
         final StringBuilder valueBuilder = new StringBuilder();
         switch (type) {
             case DDF_EMPTY:
-            case DDF_POINTER:
                 if (ch != 0x0A) {
-                    throw new IOException("Empty/pointer record not terminated by linefeed");
+                    throw new IOException("Empty record not terminated by linefeed");
                 }
                 // Nothing else to do, it's already empty.
                 return obj;
diff --git a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/DDFTest.java b/sp-server-api/src/test/java/net/shibboleth/sp/ddf/DDFTest.java
index 61ca095..6452918 100644
--- a/sp-server-api/src/test/java/net/shibboleth/sp/ddf/DDFTest.java
+++ b/sp-server-api/src/test/java/net/shibboleth/sp/ddf/DDFTest.java
@@ -124,8 +124,7 @@ public class DDFTest {
         
         obj.add(new DDF("foo", "bar"));
         obj.add(new DDF("foo2", 42));
-        obj.add(new DDF("foo3").pointer(new Pair<>()));
-        assertEquals(obj.integer(), Integer.valueOf(3));
+        assertEquals(obj.integer(), Integer.valueOf(2));
         
         for (final DDF el : obj) {
             final String name = el.name();
@@ -139,10 +138,6 @@ public class DDFTest {
                     assertEquals(el.integer(), Integer.valueOf(42));
                     break;
                         
-                case "foo3":
-                    assertEquals(el.pointer(), new Pair<>());
-                    break;
-                        
                 default:
                     fail("Node unrecognized");
             }
@@ -150,20 +145,16 @@ public class DDFTest {
         
         assertEquals(obj.getmember("[0]"), new DDF("foo", "bar"));
         assertEquals(obj.getmember("[1]"), new DDF("foo2", 42));
-        assertTrue(obj.getmember("[3]").isnull());
         
         obj.addafter(new DDF(null), obj.getmember("[0]"));
-        assertEquals(obj.integer(), Integer.valueOf(4));
+        assertEquals(obj.integer(), Integer.valueOf(3));
         assertTrue(obj.getmember("[1]").isempty());
 
-        obj.addbefore(new DDF("foo4"), obj.getmember("[2]"));
-        assertEquals(obj.integer(), Integer.valueOf(5));
+        obj.addbefore(new DDF("foo3"), obj.getmember("[2]"));
+        assertEquals(obj.integer(), Integer.valueOf(4));
         final String name = obj.getmember("[2]").name();
         assert name != null;
-        assertTrue(name.equals("foo4"));
-        
-        assertTrue(obj.asList().get(4).remove().ispointer());
-        assertEquals(obj.integer(), Integer.valueOf(4));
+        assertTrue(name.equals("foo3"));
     }
 
     @Test
diff --git a/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/long-name.ddf b/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/long-name.ddf
index f1c355e..15f33f8 100644
--- a/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/long-name.ddf
+++ b/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/long-name.ddf
@@ -1 +1 @@
-foo%20bar 8 42000000000
+foo%20bar 7 42000000000
diff --git a/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/unsafestring-name.ddf b/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/unsafestring-name.ddf
index 02eccdc..6991384 100644
--- a/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/unsafestring-name.ddf
+++ b/sp-server-api/src/test/resources/net/shibboleth/sp/ddf/unsafestring-name.ddf
@@ -1 +1 @@
-foo%20bar 7 foo%80bar
+foo%20bar 6 foo%80bar

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


More information about the commits mailing list