[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes
Ian Young
ian at iay.org.uk
Wed May 1 15:55:21 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=5a260446834597e5c4669a8618e195cbc24fc1fb
The following commit(s) were added to refs/heads/main by this push:
new 5a26044 MDA-245 - Terminology changes
5a26044 is described below
commit 5a260446834597e5c4669a8618e195cbc24fc1fb
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Wed May 1 16:55:18 2024 +0100
MDA-245 - Terminology changes
https://shibboleth.atlassian.net/browse/MDA-245
---
.../saml/mdattr/EntityAttributeFilteringStage.java | 69 +++++++++++++++++-----
.../mdattr/EntityAttributeFilteringStageTest.java | 28 ++++++++-
...ml => EntityAttributeFilteringStage-remove.xml} | 0
3 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
index 82e2418..e1c409a 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
@@ -37,22 +37,31 @@ import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+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 stage which filters entity attributes from entity definitions according to a supplied
* set of rules.
- *
+ *
+ * <p>
* For each attribute value under consideration, a {@link EntityAttributeContext} is built
* from the components of the attribute and the entity's <code>registrationAuthority</code>,
* if any.
- *
+ * </p>
+ *
+ * <p>
* Note that the <code>registrationAuthority</code> to be used is assumed to have been
* extracted out into a {@link RegistrationAuthority} object in the entity's item metadata.
- *
- * The stage can be operated in a whitelisting mode (the default) or in a blacklisting mode
- * by setting the <code>whitelisting</code> property to <code>false</code>.
+ * </p>
+ *
+ * <p>
+ * By default, the stage operates to keep matched entity attributes and discard any others.
+ * It can be set to remove matched attributes instead by setting the <code>keeping</code>
+ * property to <code>false</code>.
+ * </p>
*
* @since 0.9.0
*/
@@ -204,8 +213,8 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
@Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
private List<Predicate<EntityAttributeContext>> rules = CollectionSupport.emptyList();
- /** Mode of operation: whitelisting or blacklisting. Default: whitelisting. */
- @GuardedBy("this") private boolean whitelisting = true;
+ /** Mode of operation: keeping matched attributes or removing them. Default: keeping. */
+ @GuardedBy("this") private boolean keeping = true;
/** Whether we add status metadata to the item when entity attributes are removed. Default: no. */
@GuardedBy("this") private boolean recordingRemovals;
@@ -234,22 +243,50 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
/**
* Sets the mode of operation.
*
- * @param newValue <code>true</code> to whitelist (default),
- * <code>false</code> to blacklist
+ * @param newValue <code>true</code> to keep matched attributes (default),
+ * <code>false</code> to remove
+ * @since 0.10.0
*/
- public synchronized void setWhitelisting(final boolean newValue) {
+ public synchronized void setKeeping(final boolean newValue) {
checkSetterPreconditions();
- whitelisting = newValue;
+ keeping = newValue;
+ }
+
+ /**
+ * Indicates whether the stage is set to keeping or removing mode.
+ *
+ * @return <code>true</code> if keeping matched attributes (default),
+ * <code>false</code> if removing
+ * @since 0.10.0
+ */
+ public final synchronized boolean isKeeping() {
+ return keeping;
+ }
+
+ /**
+ * Sets the mode of operation.
+ *
+ * @param newValue <code>true</code> to keep matched attributes (default),
+ * <code>false</code> to remove
+ */
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public synchronized void setWhitelisting(final boolean newValue) {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelisting",
+ "EntityAttributeFilteringStage", "setKeeping");
+ setKeeping(newValue);
}
/**
- * Indicates whether the stage is set to whitelisting or blacklisting mode.
+ * Indicates whether the stage is set to keeping or removing mode.
*
- * @return <code>true</code> if whitelisting (default),
- * <code>false</code> if blacklisting
+ * @return <code>true</code> if keeping matched attributes (default),
+ * <code>false</code> if removing
*/
+ @Deprecated(forRemoval=true, since="0.10.0")
public final synchronized boolean isWhitelisting() {
- return whitelisting;
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelisting",
+ "EntityAttributeFilteringStage", "isKeeping");
+ return isKeeping();
}
/**
@@ -332,7 +369,7 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
new ContextImpl(attributeValue, attributeName,
attributeNameFormat, registrationAuthority);
final boolean matched = applyRules(ctx);
- if (matched ^ isWhitelisting()) {
+ if (matched ^ isKeeping()) {
LOG.debug("removing {}", ctx);
if (isRecordingRemovals()) {
item.getItemMetadata().put(new WarningStatus(ensureId(),
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStageTest.java
index 339a0a9..113218b 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStageTest.java
@@ -170,6 +170,28 @@ public class EntityAttributeFilteringStageTest extends BaseDOMTest {
assertXMLIdentical(expected, result);
}
+ @Test
+ public void testKeeping() throws Exception {
+ final List<Item<Element>> items = makeInputItems();
+ final List<Predicate<EntityAttributeContext>> rules = new ArrayList<>();
+ rules.add(new EntityCategoryMatcher("http://www.geant.net/uri/dataprotection-code-of-conduct/v1",
+ "http://ukfederation.org.uk"));
+
+ final EntityAttributeFilteringStage stage = new EntityAttributeFilteringStage();
+ stage.setId("id");
+ stage.setKeeping(false);
+ stage.setRules(rules);
+ stage.initialize();
+ stage.execute(items);
+ stage.destroy();
+
+ final Element result = items.get(0).unwrap();
+ final Element expected = readXMLData("remove.xml");
+ assertXMLIdentical(expected, result);
+ }
+
+ // Test legacy API
+ @Deprecated(forRemoval=true, since="0.10.0")
@Test
public void testBlacklist() throws Exception {
final List<Item<Element>> items = makeInputItems();
@@ -186,7 +208,7 @@ public class EntityAttributeFilteringStageTest extends BaseDOMTest {
stage.destroy();
final Element result = items.get(0).unwrap();
- final Element expected = readXMLData("blacklist.xml");
+ final Element expected = readXMLData("remove.xml");
assertXMLIdentical(expected, result);
}
@@ -272,7 +294,7 @@ public class EntityAttributeFilteringStageTest extends BaseDOMTest {
final EntityAttributeFilteringStage stage = new EntityAttributeFilteringStage();
stage.setId("id");
stage.setRules(rules);
- stage.setWhitelisting(false);
+ stage.setKeeping(false);
stage.initialize();
stage.execute(items);
stage.destroy();
@@ -293,7 +315,7 @@ public class EntityAttributeFilteringStageTest extends BaseDOMTest {
stage.setId("id");
stage.setRules(rules);
stage.setRecordingRemovals(true);
- stage.setWhitelisting(false);
+ stage.setKeeping(false);
stage.initialize();
stage.execute(items);
stage.destroy();
diff --git a/mda-framework/src/test/resources/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage-blacklist.xml b/mda-framework/src/test/resources/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage-remove.xml
similarity index 100%
rename from mda-framework/src/test/resources/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage-blacklist.xml
rename to mda-framework/src/test/resources/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage-remove.xml
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list