[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes

Ian Young ian at iay.org.uk
Wed May 8 11:02:47 UTC 2024


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

iay pushed a commit to branch main
in repository java-metadata-aggregator.

View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=89ea9cb231864c424511412ba68e4d5927d8fbdc

The following commit(s) were added to refs/heads/main by this push:
     new 89ea9cb  MDA-245 - Terminology changes
89ea9cb is described below

commit 89ea9cb231864c424511412ba68e4d5927d8fbdc
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 8 12:02:45 2024 +0100

    MDA-245 - Terminology changes
    
    https://shibboleth.atlassian.net/browse/MDA-245
---
 .../metadata/dom/saml/EntityRoleFilterStage.java   | 57 ++++++++++++++-----
 .../dom/saml/EntityRoleFilterStageTest.java        | 66 ++++++++++++++++------
 2 files changed, 92 insertions(+), 31 deletions(-)

diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
index 3b9432d..023459b 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
@@ -32,7 +32,9 @@ import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
 import net.shibboleth.shared.annotation.constraint.NonnullElements;
 import net.shibboleth.shared.annotation.constraint.Unmodifiable;
 import net.shibboleth.shared.collection.CollectionSupport;
+import net.shibboleth.shared.primitive.DeprecationSupport;
 import net.shibboleth.shared.primitive.LoggerFactory;
+import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
 import net.shibboleth.shared.xml.DOMTypeSupport;
 import net.shibboleth.shared.xml.ElementSupport;
 import net.shibboleth.shared.xml.QNameSupport;
@@ -40,8 +42,10 @@ import net.shibboleth.shared.xml.QNameSupport;
 /**
  * A pipeline stage that will filter SAML role descriptors from EntityDescriptors.
  * 
+ * <p>
  * This filter will work on {@link Element} items that are entity or entities descriptors. In the case of
- * EntitiesDescriptors the role filter will effect all descendant EntityDescriptors.
+ * {@code EntitiesDescriptor}s the role filter will effect all descendant {@code EntityDescriptor}s.
+ * </p>
  */
 @ThreadSafe
 public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
@@ -61,12 +65,12 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
     /** Class logger. */
     private static final @Nonnull Logger LOG = LoggerFactory.getLogger(EntityRoleFilterStage.class);
 
-    /** Role element or type names which are white/black listed depending on the value of {@link #whitelistingRoles}. */
+    /** Role element or type names which are kept or removed depending on the value of {@link #keepingRoles}. */
     @Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
     private Set<QName> designatedRoles = CollectionSupport.emptySet();
 
-    /** Whether {@link #designatedRoles} should be considered a whitelist or a blacklist. Default value: false */
-    @GuardedBy("this") private boolean whitelistingRoles;
+    /** Whether {@link #designatedRoles} should be kept or removed. Default value: removed ({code false}) */
+    @GuardedBy("this") private boolean keepingRoles;
 
     /**
      * Whether EntityDescriptor elements that do not contain roles, after filtering, should be removed. Default value:
@@ -98,22 +102,49 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
     }
 
     /**
-     * Gets whether the list of designated roles should be considered a whitelist.
+     * Gets whether the stage is keeping the list of designated roles.
      * 
-     * @return true if the designated roles should be considered a whitelist, false otherwise
+     * @return {@code true} if the designated roles should be kept, {@code false} otherwise
+     *
+     * @since 0.10.0
      */
-    public final synchronized boolean isWhitelistingRoles() {
-        return whitelistingRoles;
+    public final synchronized boolean isKeepingRoles() {
+        return keepingRoles;
     }
 
     /**
-     * Sets whether the list of designated roles should be considered a whitelist.
+     * Sets whether to keep the designated roles.
      * 
-     * @param whitelisting true if the designated entities should be considered a whitelist, false otherwise
+     * @param keeping {@code true} if the designated roles should be kept, {@code false} otherwise
+     *
+     * @since 0.10.0
      */
-    public synchronized void setWhitelistingRoles(final boolean whitelisting) {
+    public synchronized void setKeepingRoles(final boolean keeping) {
         checkSetterPreconditions();
-        whitelistingRoles = whitelisting;
+        keepingRoles = keeping;
+    }
+    /**
+     * Gets whether the stage is keeping the list of designated roles.
+     * 
+     * @return {@code true} if the designated roles should be kept, {@code false} otherwise
+     */
+    @Deprecated(since="0.10.0", forRemoval=true)
+    public final synchronized boolean isWhitelistingRoles() {
+        DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelistingRoles",
+                "EntityRoleFilterStage", "isKeepingRoles");
+        return isKeepingRoles();
+    }
+
+    /**
+     * Sets whether to keep the designated roles.
+     * 
+     * @param keeping {@code true} if the designated roles should be kept, {@code false} otherwise
+     */
+    @Deprecated(since="0.10.0", forRemoval=true)
+    public synchronized void setWhitelistingRoles(final boolean keeping) {
+        DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelistingRoles",
+                "EntityRoleFilterStage", "setKeepingRoles");
+        setKeepingRoles(keeping);
     }
 
     /**
@@ -264,7 +295,7 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
 
             if (roleIdentifier != null) {
                 final boolean isDesignatedRole = getDesignatedRoles().contains(roleIdentifier);
-                if (isWhitelistingRoles() && !isDesignatedRole || !isWhitelistingRoles() && isDesignatedRole) {
+                if (isKeepingRoles() && !isDesignatedRole || !isKeepingRoles() && isDesignatedRole) {
                     LOG.debug("{} pipeline stage removing role {} from EntityDescriptor {}", new Object[] {getId(),
                             roleIdentifier, entityId,});
                     entityDescriptor.removeChild(child);
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStageTest.java
index 9d5a2e8..5d9e493 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStageTest.java
@@ -37,14 +37,8 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
         super(EntityRoleFilterStage.class);
     }
 
-    /**
-     * Test that whitelisted roles are retained and all other roles are removed. Also tests that roleless entities are
-     * removed.
-     * 
-     * @throws Exception if something bad happens
-     */
     @Test
-    public void testRoleWhitelist() throws Exception {
+    public void testKeepingLegacy() throws Exception {
         EntityRoleFilterStage stage = new EntityRoleFilterStage();
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
@@ -62,14 +56,8 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
                 .size(), 1);
     }
 
-    /**
-     * Test that blacklisted roles are removed and all other roles are retained. Also tests that roleless entities are
-     * removed.
-     * 
-     * @throws Exception if something bad happens
-     */
     @Test
-    public void testRoleBlacklist() throws Exception {
+    public void testRemovingLegacy() throws Exception {
         EntityRoleFilterStage stage = new EntityRoleFilterStage();
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
@@ -91,6 +79,48 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
                 .size(), 1);
     }
 
+    @Test
+    public void testKeeping() throws Exception {
+        EntityRoleFilterStage stage = new EntityRoleFilterStage();
+        stage.setId("test");
+        stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
+        stage.setKeepingRoles(true);
+        stage.initialize();
+
+        List<Item<Element>> metadataCollection = buildMetadataCollection();
+        stage.execute(metadataCollection);
+        stage.destroy();
+
+        Assert.assertEquals(metadataCollection.size(), 1);
+
+        Element descriptor = metadataCollection.get(0).unwrap();
+        Assert.assertEquals(ElementSupport.getChildElements(descriptor, SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME)
+                .size(), 1);
+    }
+
+    @Test
+    public void testRemoving() throws Exception {
+        EntityRoleFilterStage stage = new EntityRoleFilterStage();
+        stage.setId("test");
+        stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
+        stage.setKeepingRoles(false);
+        stage.initialize();
+
+        List<Item<Element>> metadataCollection = buildMetadataCollection();
+        stage.execute(metadataCollection);
+        stage.destroy();
+
+        Assert.assertEquals(metadataCollection.size(), 2);
+
+        Element descriptor = metadataCollection.get(0).unwrap();
+        Assert.assertEquals(ElementSupport.getChildElements(descriptor, SAMLMetadataSupport.SP_SSO_DESCRIPTOR_NAME)
+                .size(), 1);
+
+        descriptor = metadataCollection.get(1).unwrap();
+        Assert.assertEquals(ElementSupport.getChildElements(descriptor, SAMLMetadataSupport.SP_SSO_DESCRIPTOR_NAME)
+                .size(), 1);
+    }
+
     /**
      * Test that EntityDescriptors that have had all their roles removed are not themselves removed if
      * {@link EntityRoleFilterStage#isRemovingRolelessEntities()} is false.
@@ -102,7 +132,7 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
         EntityRoleFilterStage stage = new EntityRoleFilterStage();
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
-        stage.setWhitelistingRoles(true);
+        stage.setKeepingRoles(true);
         stage.setRemoveRolelessEntities(false);
         stage.initialize();
 
@@ -138,7 +168,7 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
         EntityRoleFilterStage stage = new EntityRoleFilterStage();
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME));
-        stage.setWhitelistingRoles(false);
+        stage.setKeepingRoles(false);
         stage.initialize();
 
         stage.execute(metadataCollection);
@@ -172,7 +202,7 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME,
                 SAMLMetadataSupport.SP_SSO_DESCRIPTOR_NAME));
-        stage.setWhitelistingRoles(false);
+        stage.setKeepingRoles(false);
         stage.initialize();
 
         stage.execute(metadataCollection);
@@ -196,7 +226,7 @@ public class EntityRoleFilterStageTest extends BaseDOMTest {
         stage.setId("test");
         stage.setDesignatedRoles(CollectionSupport.listOf(SAMLMetadataSupport.IDP_SSO_DESCRIPTOR_NAME,
                 SAMLMetadataSupport.SP_SSO_DESCRIPTOR_NAME));
-        stage.setWhitelistingRoles(false);
+        stage.setKeepingRoles(false);
         stage.setRemovingEntitylessEntitiesDescriptor(false);
         stage.initialize();
 

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


More information about the commits mailing list