[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes
Ian Young
ian at iay.org.uk
Wed May 8 10:46:49 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=c8b09c32955a3e513619d176e270f2feb4c812a3
The following commit(s) were added to refs/heads/main by this push:
new c8b09c3 MDA-245 - Terminology changes
c8b09c3 is described below
commit c8b09c32955a3e513619d176e270f2feb4c812a3
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 8 11:46:44 2024 +0100
MDA-245 - Terminology changes
https://shibboleth.atlassian.net/browse/MDA-245
---
.../metadata/dom/saml/EntityFilterStage.java | 76 ++++++++++++++++------
.../metadata/dom/saml/EntityFilterStageTest.java | 61 +++++++++++------
2 files changed, 97 insertions(+), 40 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
index 84a7f02..6d20bee 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
@@ -30,24 +30,35 @@ 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.ElementSupport;
-/** A pipeline stage that will remove SAML EntityDescriptior elements which do meet specified filtering criteria. */
+/**
+ * A pipeline stage that will remove SAML {@code EntityDescriptor} elements which
+ * meet specified filtering criteria.
+ */
@ThreadSafe
public class EntityFilterStage extends AbstractFilteringStage<Element> {
/** Class logger. */
private static final @Nonnull Logger LOG = LoggerFactory.getLogger(EntityFilterStage.class);
- /** Entities which are white/black listed depending on the value of {@link #whitelistingEntities}. */
+ /**
+ * Entities which are kept or removed depending on the value of {@link #keepingEntities}. */
@Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
private Set<String> designatedEntities = CollectionSupport.emptySet();
- /** Whether {@link #designatedEntities} should be considered a whitelist or a blacklist. Default value: false */
- @GuardedBy("this") private boolean whitelistingEntities;
+ /**
+ * Whether to keep or remove the entities listed in {@link #designatedEntities}. Default value: removing ({@code false}).
+ */
+ @GuardedBy("this") private boolean keepingEntities;
- /** Whether EntitiesDescriptor that do not contain EntityDescriptors should be removed. Default value: true */
+ /**
+ * Whether {@code EntitiesDescriptor}s that do not contain {@code EntityDescriptor}s should
+ * be removed. Default value: {@code true}
+ */
@GuardedBy("this") private boolean removingEntitylessEntitiesDescriptor = true;
/**
@@ -72,22 +83,49 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
}
/**
- * Whether the list of designated entities should be considered a whitelist.
+ * Whether the stage is keeping or removing the designated entities.
*
- * @return true if the designated entities should be considered a whitelist, false otherwise
+ * @return {@code true} if keeping, {@code false} otherwise
+ *
+ * @since 0.10.0
*/
- public final synchronized boolean isWhitelistingEntities() {
- return whitelistingEntities;
+ public final synchronized boolean isKeepingEntities() {
+ return keepingEntities;
}
/**
- * Sets whether the list of designated entities should be considered a whitelist.
+ * Sets whether to keep or remove the designated entities.
*
- * @param whitelisting true if the designated entities should be considered a whitelist, false otherwise
+ * @param keeping {@code true} if the designated entities should be kept, {@code false} otherwise
+ *
+ * @since 0.10.0
*/
- public synchronized void setWhitelistingEntities(final boolean whitelisting) {
+ public synchronized void setKeepingEntities(final boolean keeping) {
checkSetterPreconditions();
- whitelistingEntities = whitelisting;
+ keepingEntities = keeping;
+ }
+ /**
+ * Whether the stage is keeping or removing the designated entities.
+ *
+ * @return {@code true} if keeping, {@code false} otherwise
+ */
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public final synchronized boolean isWhitelistingEntities() {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelistingEntities",
+ "EntityFilterStage", "isKeepingEntities");
+ return isKeepingEntities();
+ }
+
+ /**
+ * Sets whether to keep or remove the designated entities.
+ *
+ * @param keeping {@code true} if the designated entities should be kept, {@code false} otherwise
+ */
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public synchronized void setWhitelistingEntities(final boolean keeping) {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelistingEntities",
+ "EntityFilterStage", "setKeepingEntities");
+ setKeepingEntities(keeping);
}
/**
@@ -177,15 +215,15 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
protected boolean processEntityDescriptor(@Nonnull final Element entityDescriptor) {
final String entityId = SAMLMetadataSupport.getEntityID(entityDescriptor);
- // if we're whitelisting entities and this entity isn't in the list, kick it out
- if (isWhitelistingEntities() && !getDesignatedEntities().contains(entityId)) {
- LOG.debug("{} pipeline stage removing entity {} because it wasn't on the whitelist", getId(), entityId);
+ // if we're keeping entities and this entity isn't in the list, kick it out
+ if (isKeepingEntities() && !getDesignatedEntities().contains(entityId)) {
+ LOG.debug("{} pipeline stage removing entity {} because it wasn't in the list", getId(), entityId);
return true;
}
- // if we're backlisting entities and this entity is in the list, kick it out
- if (!isWhitelistingEntities() && getDesignatedEntities().contains(entityId)) {
- LOG.debug("{} pipeline stage removing entity {} because it was on the blacklist", getId(), entityId);
+ // if we're removing entities and this entity is in the list, kick it out
+ if (!isKeepingEntities() && getDesignatedEntities().contains(entityId)) {
+ LOG.debug("{} pipeline stage removing entity {} because it was on the list", getId(), entityId);
return true;
}
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityFilterStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityFilterStageTest.java
index bb7076e..9939792 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityFilterStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/EntityFilterStageTest.java
@@ -37,12 +37,7 @@ public class EntityFilterStageTest extends BaseDOMTest {
super(EntityFilterStage.class);
}
- /**
- * Test whitelisted entity is retained and ensure everything else is removed.
- *
- * @throws Exception if something bad happens
- */
- @Test public void testEntityWhitelist() throws Exception {
+ @Test public void testKeepingLegacy() throws Exception {
final EntityFilterStage stage = new EntityFilterStage();
stage.setId("test");
stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth"));
@@ -56,12 +51,7 @@ public class EntityFilterStageTest extends BaseDOMTest {
Assert.assertEquals(metadataCollection.size(), 1);
}
- /**
- * Test blacklisted entity is remove and ensure everything else is retained.
- *
- * @throws Exception if something bad happens
- */
- @Test public void testEntityBlacklist() throws Exception {
+ @Test public void testRemovingLegacy() throws Exception {
final EntityFilterStage stage = new EntityFilterStage();
stage.setId("test");
stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth"));
@@ -75,6 +65,35 @@ public class EntityFilterStageTest extends BaseDOMTest {
Assert.assertEquals(metadataCollection.size(), 2);
}
+
+ @Test public void testKeeping() throws Exception {
+ final EntityFilterStage stage = new EntityFilterStage();
+ stage.setId("test");
+ stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth"));
+ stage.setKeepingEntities(true);
+ stage.initialize();
+
+ final var metadataCollection = buildMetadataCollection();
+ stage.execute(metadataCollection);
+ stage.destroy();
+
+ Assert.assertEquals(metadataCollection.size(), 1);
+ }
+
+ @Test public void testRemoving() throws Exception {
+ final EntityFilterStage stage = new EntityFilterStage();
+ stage.setId("test");
+ stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth"));
+ stage.setKeepingEntities(false);
+ stage.initialize();
+
+ final var metadataCollection = buildMetadataCollection();
+ stage.execute(metadataCollection);
+ stage.destroy();
+
+ Assert.assertEquals(metadataCollection.size(), 2);
+ }
+
/**
* Test that filtering logic descends in to EntitiesDescriptors.
*
@@ -87,7 +106,7 @@ public class EntityFilterStageTest extends BaseDOMTest {
final EntityFilterStage stage = new EntityFilterStage();
stage.setId("test");
stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth"));
- stage.setWhitelistingEntities(false);
+ stage.setKeepingEntities(false);
stage.initialize();
stage.execute(metadataCollection);
stage.destroy();
@@ -109,7 +128,7 @@ public class EntityFilterStageTest extends BaseDOMTest {
stage.setId("test");
stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth",
"https://issues.shibboleth.net/shibboleth", "https://wiki.shibboleth.net/shibboleth"));
- stage.setWhitelistingEntities(false);
+ stage.setKeepingEntities(false);
stage.initialize();
stage.execute(metadataCollection);
stage.destroy();
@@ -132,7 +151,7 @@ public class EntityFilterStageTest extends BaseDOMTest {
stage.setRemovingEntitylessEntitiesDescriptor(false);
stage.setDesignatedEntities(CollectionSupport.listOf("https://idp.shibboleth.net/idp/shibboleth",
"https://issues.shibboleth.net/shibboleth", "https://wiki.shibboleth.net/shibboleth"));
- stage.setWhitelistingEntities(false);
+ stage.setKeepingEntities(false);
stage.initialize();
stage.execute(metadataCollection);
stage.destroy();
@@ -141,16 +160,16 @@ public class EntityFilterStageTest extends BaseDOMTest {
}
/**
- * Test that whitelisting an empty set of IDs removes everything from the collection.
+ * Test that keeping an empty set of IDs removes everything from the collection.
*
* @throws Exception if something bad happens
*/
- @Test public void testWhitelistEmptySet() throws Exception {
+ @Test public void testKeepingEmptySet() throws Exception {
final var metadataCollection = buildMetadataCollection();
final var stage = new EntityFilterStage();
stage.setId("test");
- stage.setWhitelistingEntities(true);
+ stage.setKeepingEntities(true);
stage.setDesignatedEntities(CollectionSupport.emptySet());
stage.initialize();
stage.execute(metadataCollection);
@@ -160,16 +179,16 @@ public class EntityFilterStageTest extends BaseDOMTest {
}
/**
- * Test that blacklisting an empty set of IDs leaves everything in the collection.
+ * Test that removing an empty set of IDs leaves everything in the collection.
*
* @throws Exception if something bad happens
*/
- @Test public void testBlacklistEmptySet() throws Exception {
+ @Test public void testRemovingEmptySet() throws Exception {
final var metadataCollection = buildMetadataCollection();
final var stage = new EntityFilterStage();
stage.setId("test");
- stage.setWhitelistingEntities(false);
+ stage.setKeepingEntities(false);
stage.setDesignatedEntities(CollectionSupport.emptySet());
stage.initialize();
stage.execute(metadataCollection);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list