[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes
Ian Young
ian at iay.org.uk
Thu May 2 15:47:04 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=9f7d1c17cc8359bb38c7676d17bcbd1009c7d3ab
The following commit(s) were added to refs/heads/main by this push:
new 9f7d1c1 MDA-245 - Terminology changes
9f7d1c1 is described below
commit 9f7d1c17cc8359bb38c7676d17bcbd1009c7d3ab
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu May 2 16:46:59 2024 +0100
MDA-245 - Terminology changes
https://shibboleth.atlassian.net/browse/MDA-245
---
.../EntityRegistrationAuthorityFilterStage.java | 108 +++++++++++++++------
...EntityRegistrationAuthorityFilterStageTest.java | 53 +++++++---
2 files changed, 117 insertions(+), 44 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
index b8bf517..90ad8e3 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
@@ -31,11 +31,16 @@ 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.AttributeSupport;
import net.shibboleth.shared.xml.ElementSupport;
-/** A pipeline stage that will filter EntityDescriptor or EntityDescriptors based on their registration authority. */
+/**
+ * A pipeline stage that will filter {@code EntityDescriptor} or {@code EntityDescriptors}
+ * based on their registration authorities.
+ */
@ThreadSafe
public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringStage<Element> {
@@ -45,14 +50,23 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
/** Whether a descriptor is required to have registration information. Default value: false */
@GuardedBy("this") private boolean requiringRegistrationInformation;
- /** Registrars which are white/black listed depending on the value of {@link #whitelistingAuthorities}. */
+ /**
+ * Registration authorities from which entities are kept or removed depending on the value
+ * of {@link #keepingAuthorities}.
+ */
@Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
private Set<String> designatedAuthorities = CollectionSupport.emptySet();
- /** Whether {@link #designatedAuthorities} should be considered a whitelist or a blacklist. Default value: false */
- @GuardedBy("this") private boolean whitelistingAuthorities;
+ /**
+ * Whether {@link #designatedAuthorities} lists registration authorities which should be kept ({@code true})
+ * or removed ({@code false}). Default value: removed ({@code false}).
+ */
+ @GuardedBy("this") private boolean keepingAuthorities;
- /** Whether EntitiesDescriptor that do not contain EntityDescriptors should be removed. Default value: true */
+ /**
+ * Whether {@code EntitiesDescriptor} elements that do not contain {@code EntityDescriptor}
+ * elements should be removed. Default value: {@code true}.
+ */
@GuardedBy("this") private boolean removingEntitylessEntitiesDescriptor = true;
/**
@@ -75,9 +89,9 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
}
/**
- * Gets the list of designated registration authority.
+ * Gets the list of designated registration authorities.
*
- * @return list of designated registration authority, never null
+ * @return list of designated registration authorities, never {@code null}
*/
@Nonnull @NonnullElements @Unmodifiable
public final synchronized Collection<String> getDesignatedRegistrationAuthorities() {
@@ -85,9 +99,9 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
}
/**
- * Sets the list of designated registration authority.
+ * Sets the list of designated registration authorities.
*
- * @param authorities list of designated registration authority
+ * @param authorities list of designated registration authorities
*/
public synchronized void setDesignatedRegistrationAuthorities(
@Nonnull @NonnullElements @Unmodifiable final Collection<String> authorities) {
@@ -96,23 +110,52 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
}
/**
- * Whether the list of designated registration authority should be considered a whitelist.
+ * Whether entities from the designated registration authorities should be
+ * kept ({@code true}) or removed ({@code false)}.
*
- * @return true if the designated registration authority should be considered a whitelist, false otherwise
+ * @return {@code true} if entities from the designated registration authorities
+ * should be kept, otherwise {@code false}
*/
- public final synchronized boolean isWhitelistingRegistrationAuthorities() {
- return whitelistingAuthorities;
+ public final synchronized boolean isKeepingRegistrationAuthorities() {
+ return keepingAuthorities;
}
/**
- * Sets whether the list of designated registration authority should be considered a whitelist.
+ * Sets whether entities from the designated registration authorities should be kept or removed.
*
- * @param whitelisting true if the designated registration authority should be considered a whitelist, false
- * otherwise
+ * @param keeping {@code true} if entities from the designated registration authorities
+ * should be kept, {@code false} if they should be removed
*/
- public synchronized void setWhitelistingRegistrationAuthorities(final boolean whitelisting) {
+ public synchronized void setKeepingRegistrationAuthorities(final boolean keeping) {
checkSetterPreconditions();
- whitelistingAuthorities = whitelisting;
+ keepingAuthorities = keeping;
+ }
+
+ /**
+ * Whether entities from the designated registration authorities should be
+ * kept ({@code true}) or removed ({@code false)}.
+ *
+ * @return {@code true} if entities from the designated registration authorities
+ * should be kept, otherwise {@code false}
+ */
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public final synchronized boolean isWhitelistingRegistrationAuthorities() {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelistingRegistrationAuthorities",
+ "EntityRegistrationAuthorityFilterStage", "isKeepingRegistrationAuthorities");
+ return isKeepingRegistrationAuthorities();
+ }
+
+ /**
+ * Sets whether entities from the designated registration authorities should be kept or removed.
+ *
+ * @param keeping {@code true} if entities from the designated registration authorities
+ * should be kept, {@code false} if they should be removed
+ */
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public synchronized void setWhitelistingRegistrationAuthorities(final boolean keeping) {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelistingRegistrationAuthorities",
+ "EntityRegistrationAuthorityFilterStage", "setKeepingRegistrationAuthorities");
+ setKeepingRegistrationAuthorities(keeping);
}
/**
@@ -197,17 +240,24 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
}
/**
- * Determines if a given EntityDescriptor or EntitiesDecriptor should be filtered out.
+ * Determines if a given {@code EntityDescriptor} or {@code EntitiesDecriptor}
+ * should be filtered out.
*
- * A descriptor is filtered out if registration information is
- * required by the descriptor does not have it, registration information is present but does not contain the
- * required authority attribute, registrars are being whitelisted and the descriptor's registration authority is not
- * in the whitelist, or registrars are being blacklisted and the descriptor's registration authority is in the
- * blacklist.
+ * <p>
+ * A descriptor is filtered out if:
+ * </p>
+ * <ul>
+ * <li>Registration information is required but the descriptor does not have it, or</li>
+ * <li>Registration information is present but does not contain the required authority attribute, or</li>
+ * <li>The list of designated authorities is a list of authorities to be kept and the
+ * descriptor's registration authority is not in the list, or</li>
+ * <li>The list of designated authorities is a list of authorities to be removed and the
+ * descriptor's registration authority is in the list.</li>
+ * </ul>
*
* @param descriptor the descriptor
*
- * @return true if the descriptor should be filtered out
+ * @return {@code true} if the descriptor should be filtered out
*/
protected boolean filterOutDescriptor(@Nonnull final Element descriptor) {
final Element registrationInfoElement =
@@ -233,16 +283,16 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
return true;
}
- if (isWhitelistingRegistrationAuthorities() &&
+ if (isKeepingRegistrationAuthorities() &&
!getDesignatedRegistrationAuthorities().contains(registrationAuthority)) {
- LOG.debug("{} pipeline stage removing Item because its registration authority was not on the whitelist",
+ LOG.debug("{} pipeline stage removing Item because its registration authority was not on the list",
getId());
return true;
}
- if (!isWhitelistingRegistrationAuthorities() &&
+ if (!isKeepingRegistrationAuthorities() &&
getDesignatedRegistrationAuthorities().contains(registrationAuthority)) {
- LOG.debug("{} pipeline stage removing Item because its registration authority was on the blacklist",
+ LOG.debug("{} pipeline stage removing Item because its registration authority was on the list",
getId());
return true;
}
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStageTest.java
index 8ca2a2a..77e147d 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStageTest.java
@@ -35,13 +35,26 @@ public class EntityRegistrationAuthorityFilterStageTest extends BaseDOMTest {
super(EntityRegistrationAuthorityFilterStage.class);
}
- /**
- * Tests filtering out Items based on an authority whitelist.
- *
- * @throws Exception if something bad happens
- */
@Test
- public void testAuthorityWhitelist() throws Exception {
+ public void testKeeping() throws Exception {
+ EntityRegistrationAuthorityFilterStage stage = new EntityRegistrationAuthorityFilterStage();
+ stage.setId("test");
+ stage.setRequiringRegistrationInformation(false);
+ stage.setKeepingRegistrationAuthorities(true);
+ stage.setDesignatedRegistrationAuthorities(CollectionSupport.listOf("urn:example.org:authority2"));
+ stage.initialize();
+
+ final var mdCollection = buildMetadataCollection();
+ Assert.assertEquals(mdCollection.size(), 3);
+
+ stage.execute(mdCollection);
+ stage.destroy();
+ Assert.assertEquals(mdCollection.size(), 2);
+ }
+
+ @Test
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public void testKeepingLegacy() throws Exception {
EntityRegistrationAuthorityFilterStage stage = new EntityRegistrationAuthorityFilterStage();
stage.setId("test");
stage.setRequiringRegistrationInformation(false);
@@ -57,13 +70,26 @@ public class EntityRegistrationAuthorityFilterStageTest extends BaseDOMTest {
Assert.assertEquals(mdCollection.size(), 2);
}
- /**
- * Tests filtering out Items based on an authority blacklist.
- *
- * @throws Exception if something bad happens
- */
@Test
- public void testAuthorityBlacklist() throws Exception {
+ public void testRemoving() throws Exception {
+ EntityRegistrationAuthorityFilterStage stage = new EntityRegistrationAuthorityFilterStage();
+ stage.setId("test");
+ stage.setKeepingRegistrationAuthorities(false);
+ stage.setRequiringRegistrationInformation(false);
+ stage.setDesignatedRegistrationAuthorities(CollectionSupport.listOf("urn:example.org:authority2"));
+ stage.initialize();
+
+ final var mdCollection = buildMetadataCollection();
+ Assert.assertEquals(mdCollection.size(), 3);
+
+ stage.execute(mdCollection);
+ stage.destroy();
+ Assert.assertEquals(mdCollection.size(), 1);
+ }
+
+ @Test
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public void testRemovingLegacy() throws Exception {
EntityRegistrationAuthorityFilterStage stage = new EntityRegistrationAuthorityFilterStage();
stage.setId("test");
stage.setWhitelistingRegistrationAuthorities(false);
@@ -89,7 +115,6 @@ public class EntityRegistrationAuthorityFilterStageTest extends BaseDOMTest {
EntityRegistrationAuthorityFilterStage stage = new EntityRegistrationAuthorityFilterStage();
stage.setId("test");
stage.setRequiringRegistrationInformation(true);
- stage.setWhitelistingRegistrationAuthorities(false);
stage.setDesignatedRegistrationAuthorities(CollectionSupport.listOf("urn:example.org:authority1",
"urn:example.org:authority2"));
stage.initialize();
@@ -114,7 +139,6 @@ public class EntityRegistrationAuthorityFilterStageTest extends BaseDOMTest {
stage.setId("test");
stage.setRequiringRegistrationInformation(true);
stage.setRemovingEntitylessEntitiesDescriptor(true);
- stage.setWhitelistingRegistrationAuthorities(false);
stage.setDesignatedRegistrationAuthorities(CollectionSupport.listOf("urn:example.org:authority1",
"urn:example.org:authority2"));
stage.initialize();
@@ -139,7 +163,6 @@ public class EntityRegistrationAuthorityFilterStageTest extends BaseDOMTest {
stage.setId("test");
stage.setRemovingEntitylessEntitiesDescriptor(false);
stage.setRequiringRegistrationInformation(false);
- stage.setWhitelistingRegistrationAuthorities(false);
stage.setDesignatedRegistrationAuthorities(CollectionSupport.listOf("urn:example.org:authority1",
"urn:example.org:authority2"));
stage.initialize();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list