[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes
Ian Young
ian at iay.org.uk
Wed May 8 13:54:55 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=a52829076fd426ab2bb9f04dc700fa48e692cdd1
The following commit(s) were added to refs/heads/main by this push:
new a528290 MDA-245 - Terminology changes
a528290 is described below
commit a52829076fd426ab2bb9f04dc700fa48e692cdd1
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 8 14:54:53 2024 +0100
MDA-245 - Terminology changes
https://shibboleth.atlassian.net/browse/MDA-245
---
.../metadata/dom/NamespacesStrippingStage.java | 83 ++++++++++++++++------
.../metadata/dom/NamespacesStrippingStageTest.java | 36 ++++++++--
2 files changed, 93 insertions(+), 26 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
index d2801f6..ba4e00c 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
@@ -25,20 +25,30 @@ import javax.annotation.concurrent.ThreadSafe;
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.DeprecationSupport.ObjectType;
/**
* A stage which removes all evidence of a given collection of XML namespaces from each metadata item.
*
- * The stage can operate either to blacklist (the default) or whitelist the collection of namespaces.
+ * <p>
+ * The stage can operate either to remove (the default) or keep the designated namespaces.
+ * </p>
*
+ * <p>
* Elements, attributes and namespace prefix definitions associated with a given namespace will be removed
- * or retained depending on the {@link #whitelisting} property.
+ * or retained depending on the {@link #keeping} property.
+ * </p>
*
+ * <p>
* Attributes without an explicit namespace prefix will never be removed by this stage.
- *
+ * </p>
+ *
+ * <p>
* Note that because the collection is specified as <code>@NonnullElements</code>, this stage can not
- * be used in blacklisting mode to remove elements in the default namespace. It will always remove
- * elements in the default namespace if used in the whitelisting mode.
+ * be used in removing mode to remove elements in the default namespace. It will always remove
+ * elements in the default namespace if used in the keeping mode.
+ * </p>
*
* @since 0.9.0
*/
@@ -46,21 +56,22 @@ import net.shibboleth.shared.collection.CollectionSupport;
public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
/**
- * XML namespaces to whitelist or blacklist.
+ * Designated XML namespaces to process.
*/
@Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
private Set<String> namespaces = CollectionSupport.emptySet();
/**
- * Whether we are whitelisting or blacklisting (default: blacklisting).
+ * Whether we are keeping ({@code true}) or removing ({@code false}).
+ * Default: removing ({@code false}).
*/
@GuardedBy("this")
- private boolean whitelisting;
+ private boolean keeping;
/**
- * Gets the collection of namespaces being blacklisted or whitelisted.
+ * Gets the collection of designated namespaces.
*
- * @return collection of namespaces being removed
+ * @return collection of designated namespaces
*/
@Nonnull @NonnullElements @Unmodifiable
public final synchronized Collection<String> getNamespaces() {
@@ -68,9 +79,9 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
}
/**
- * Sets the collection of namespaces to blacklist or whitelist.
+ * Sets the collection of designated namespaces.
*
- * @param nss collection of namespaces
+ * @param nss collection of designated namespaces
*/
public synchronized void setNamespaces(@Nonnull @NonnullElements @Unmodifiable final Collection<String> nss) {
checkSetterPreconditions();
@@ -78,33 +89,61 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
}
/**
- * Indicate whether the stage is whitelisting namespaces or blacklisting (the default).
+ * Indicate whether the stage is keeping the designated namespaces or removing them (the default).
*
- * @return <code>true</code> for whitelisting, <code>false</code> for blacklisting (the default)
+ * @return <code>true</code> if keeping, <code>false</code> for removing (the default)
+ *
+ * @since 0.10.0
*/
- public final synchronized boolean isWhitelisting() {
- return whitelisting;
+ public final synchronized boolean isKeeping() {
+ return keeping;
}
/**
- * Set whether the stage is whitelisting namespaces.
+ * Set whether the stage is whether the stage is keeping the designated namespaces or removing them (the default).
*
- * @param wl <code>true</code> for whitelisting, <code>false</code> for blacklisting
+ * @param keep <<code>true</code> if keeping, <code>false</code> for removing (the default)
+ *
+ * @since 0.10.0
*/
- public synchronized void setWhitelisting(final boolean wl) {
+ public synchronized void setKeeping(final boolean keep) {
checkSetterPreconditions();
- whitelisting = wl;
+ keeping = keep;
+ }
+
+ /**
+ * Indicate whether the stage is keeping the designated namespaces or removing them (the default).
+ *
+ * @return <code>true</code> if keeping, <code>false</code> for removing (the default)
+ */
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public final synchronized boolean isWhitelisting() {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelisting",
+ "NamespacesStrippingStage", "isKeeping");
+ return isKeeping();
+ }
+
+ /**
+ * Set whether the stage is whether the stage is keeping the designated namespaces or removing them (the default).
+ *
+ * @param keep <<code>true</code> if keeping, <code>false</code> for removing (the default)
+ */
+ @Deprecated(since="0.10.0", forRemoval=true)
+ public synchronized void setWhitelisting(final boolean keep) {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelisting",
+ "NamespacesStrippingStage", "setKeeping");
+ setKeeping(keep);
}
@Override
protected boolean removingNamespace(@Nullable final String namespace) {
// Handle ineligible null element, for the default namespace case
if (namespace == null) {
- return isWhitelisting();
+ return isKeeping();
}
// Handle normal namespaces
- return isWhitelisting() ^ getNamespaces().contains(namespace);
+ return isKeeping() ^ getNamespaces().contains(namespace);
}
}
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/NamespacesStrippingStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/NamespacesStrippingStageTest.java
index 037911b..8d456bc 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/NamespacesStrippingStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/NamespacesStrippingStageTest.java
@@ -57,12 +57,12 @@ public class NamespacesStrippingStageTest extends BaseDOMTest {
}
/**
- * Test blacklisting.
+ * Test removing.
*
* @throws Exception if something goes wrong
*/
@Test
- public void blacklist() throws Exception {
+ public void removing() throws Exception {
final Element doc = readXMLData("2-in.xml");
final Item<Element> item = new DOMElementItem(doc);
final List<Item<Element>> items = new ArrayList<>();
@@ -83,12 +83,40 @@ public class NamespacesStrippingStageTest extends BaseDOMTest {
}
/**
- * Test whitelisting.
+ * Test keeping.
*
* @throws Exception if something goes wrong
*/
@Test
- public void whitelist() throws Exception {
+ public void keeping() throws Exception {
+ final Element doc = readXMLData("2-in.xml");
+ final Item<Element> item = new DOMElementItem(doc);
+ final List<Item<Element>> items = new ArrayList<>();
+ items.add(item);
+
+ final NamespacesStrippingStage stage = new NamespacesStrippingStage();
+ stage.setId("stripTest");
+ final List<String> namespaces = new ArrayList<>();
+ namespaces.add("urn:namespace:alfa"); // root element
+ namespaces.add("urn:namespace:bravo");
+ namespaces.add("urn:namespace:charlie");
+ stage.setNamespaces(namespaces);
+ stage.setKeeping(true);
+ stage.initialize();
+
+ stage.execute(items);
+
+ final Element out = readXMLData("2-wl.xml");
+ assertXMLIdentical(out, item.unwrap());
+ }
+
+ /**
+ * Test removing.
+ *
+ * @throws Exception if something goes wrong
+ */
+ @Test
+ public void keepingLegacy() throws Exception {
final Element doc = readXMLData("2-in.xml");
final Item<Element> item = new DOMElementItem(doc);
final List<Item<Element>> items = new ArrayList<>();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list