[java-metadata-aggregator] branch main updated: MDA-245 - Terminology changes
Ian Young
ian at iay.org.uk
Thu May 2 16:26:14 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=f45d219acf4834ed436a006b82dc97707ef01c02
The following commit(s) were added to refs/heads/main by this push:
new f45d219 MDA-245 - Terminology changes
f45d219 is described below
commit f45d219acf4834ed436a006b82dc97707ef01c02
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu May 2 17:26:11 2024 +0100
MDA-245 - Terminology changes
https://shibboleth.atlassian.net/browse/MDA-245
---
.../dom/saml/ContactPersonFilterStage.java | 72 +++++++++++++++------
.../EntityRegistrationAuthorityFilterStage.java | 4 ++
.../dom/saml/ContactPersonFilterStageTest.java | 73 ++++++++++++++++++++--
3 files changed, 127 insertions(+), 22 deletions(-)
diff --git a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
index 18d952a..a934827 100644
--- a/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
+++ b/mda-framework/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
@@ -33,23 +33,27 @@ 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.StringSupport;
+import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
import net.shibboleth.shared.xml.AttributeSupport;
import net.shibboleth.shared.xml.ElementSupport;
import net.shibboleth.shared.xml.SerializeSupport;
/**
- * Filtering stage that removes ContactPerson elements from EntityDescriptors.
+ * Filtering stage that removes {@code ContactPerson} elements from {@code EntityDescriptor}s.
*
* <p>
- * Note, only the values {@link #TECHNICAL}, {@link #SUPPORT}, {@link #ADMINISTRATIVE}, {@link #BILLING}, and
+ * Note: only the values {@link #TECHNICAL}, {@link #SUPPORT}, {@link #ADMINISTRATIVE}, {@link #BILLING}, and
* {@link #OTHER} are valid contact person types. Attempting to designate a type other than these will result in that
* type being ignored. <code>ContactPerson</code> elements which do not contain the required <code>contactType</code>
* attribute are always removed.
* </p>
+ *
* <p>
- * To remove all contact persons enable type whitelisting and provide an empty designated type set.
+ * To remove all {@code ContactPerson} elements, provide an empty designated type set and the default
+ * ({@link #keepingTypes} = {@code true}) operating mode.
* </p>
*/
@ThreadSafe
@@ -78,12 +82,16 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
/** Class logger. */
private static final @Nonnull Logger LOG = LoggerFactory.getLogger(ContactPersonFilterStage.class);
- /** Person types which are white/black listed depending on the value of {@link #whitelistingTypes}. */
+ /** Person types to match against {@code ContactPerson} elements. */
@Nonnull @NonnullElements @Unmodifiable @GuardedBy("this")
private Set<String> designatedTypes = CollectionSupport.copyToSet(ALLOWED_TYPES);
- /** Whether {@link #designatedTypes} should be considered a whitelist. Default value: true */
- @GuardedBy("this") private boolean whitelistingTypes = true;
+ /**
+ * Whether {@code ContactPerson} elements matching {@link #designatedTypes}
+ * should be kept ({@code true}) or removed ({@code false}).
+ * Default value: kept ({@code true}).
+ */
+ @GuardedBy("this") private boolean keepingTypes = true;
/**
* Gets the list of designated person types.
@@ -118,22 +126,50 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
}
/**
- * Gets whether the list of designated roles should be considered a whitelist.
+ * Gets whether the designated roles should be kept ({@code true}) or removed ({@code false}).
*
- * @return true if the designated roles should be considered a whitelist, false otherwise
+ * @return true if the designated roles should be kept ({@code true}), false otherwise
+ *
+ * @since 0.10.0
*/
- public final synchronized boolean isWhitelistingTypes() {
- return whitelistingTypes;
+ public final synchronized boolean isKeepingTypes() {
+ return keepingTypes;
}
/**
- * Sets whether the list of designated roles should be considered a whitelist.
+ * Sets whether the list of designated roles should be kept or removed.
*
- * @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 setWhitelistingTypes(final boolean whitelisting) {
+ public synchronized void setKeepingTypes(final boolean keeping) {
checkSetterPreconditions();
- whitelistingTypes = whitelisting;
+ keepingTypes = keeping;
+ }
+
+ /**
+ * Gets whether the designated roles should be kept ({@code true}) or removed ({@code false}).
+ *
+ * @return true if the designated roles should be kept ({@code true}), false otherwise
+ */
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public final synchronized boolean isWhitelistingTypes() {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "isWhitelistingTypes",
+ "ContactPersonFilterStage", "isKeepingTypes");
+ return isKeepingTypes();
+ }
+
+ /**
+ * Sets whether the list of designated roles should be kept or removed.
+ *
+ * @param keeping {@code true} if the designated roles should be kept, {@code false} otherwise
+ */
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public synchronized void setWhitelistingTypes(final boolean keeping) {
+ DeprecationSupport.warnOnce(ObjectType.METHOD, "setWhitelistingTypes",
+ "ContactPersonFilterStage", "setKeepingTypes");
+ setKeepingTypes(keeping);
}
@Override
@@ -213,13 +249,13 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
return false;
}
- if (isWhitelistingTypes() && getDesignatedTypes().contains(type)) {
- // if we're whitelisting types and the person's type appears in the designated type list, keep them
+ if (isKeepingTypes() && getDesignatedTypes().contains(type)) {
+ // if we're keeping types and the person's type appears in the designated type list, keep them
return true;
}
- if (!isWhitelistingTypes() && !getDesignatedTypes().contains(type)) {
- // if we're blacklisting types and the person's type does not appear in the designated type list, keep them
+ if (!isKeepingTypes() && !getDesignatedTypes().contains(type)) {
+ // if we're removing types and the person's type does not appear in the designated type list, keep them
return true;
}
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 90ad8e3..806d3e5 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
@@ -115,6 +115,8 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
*
* @return {@code true} if entities from the designated registration authorities
* should be kept, otherwise {@code false}
+ *
+ * @since 0.10.0
*/
public final synchronized boolean isKeepingRegistrationAuthorities() {
return keepingAuthorities;
@@ -125,6 +127,8 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
*
* @param keeping {@code true} if entities from the designated registration authorities
* should be kept, {@code false} if they should be removed
+ *
+ * @since 0.10.0
*/
public synchronized void setKeepingRegistrationAuthorities(final boolean keeping) {
checkSetterPreconditions();
diff --git a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
index c100329..048ec00 100644
--- a/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
+++ b/mda-framework/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
@@ -89,7 +89,36 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
}
}
- @Test public void testWhitelistingTypes() throws ComponentInitializationException {
+ @Test
+ public void testKeepingTypes() throws ComponentInitializationException {
+ ContactPersonFilterStage stage = new ContactPersonFilterStage();
+ stage.setId("foo");
+ Assert.assertTrue(stage.isKeepingTypes());
+
+ stage.setKeepingTypes(false);
+ Assert.assertFalse(stage.isKeepingTypes());
+
+ stage.initialize();
+ try {
+ stage.setKeepingTypes(true);
+ Assert.fail();
+ } catch (UnmodifiableComponentException e) {
+ Assert.assertFalse(stage.isKeepingTypes());
+ }
+
+ stage = new ContactPersonFilterStage();
+ stage.destroy();
+ try {
+ stage.setKeepingTypes(true);
+ Assert.fail();
+ } catch (DestroyedComponentException e) {
+ // expected this
+ }
+ }
+
+ @Test
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public void testKeepingTypesLegacy() throws ComponentInitializationException {
ContactPersonFilterStage stage = new ContactPersonFilterStage();
stage.setId("foo");
Assert.assertTrue(stage.isWhitelistingTypes());
@@ -114,8 +143,9 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
// expected this
}
}
-
- @Test public void testWhitelistContactPersons() throws Exception {
+
+ @Test
+ public void testKeepingContactPersons() throws Exception {
final @Nonnull var entitiesDescriptor = readXMLData("entities.xml");
ContactPersonFilterStage stage = new ContactPersonFilterStage();
stage.setId("foo");
@@ -145,7 +175,42 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
Assert.assertEquals(contactPersons.size(), 0);
}
- @Test public void testBlacklistContactPersons() throws Exception {
+ @Test
+ public void testRemovingContactPersons() throws Exception {
+ final @Nonnull var entitiesDescriptor = readXMLData("entities.xml");
+ ContactPersonFilterStage stage = new ContactPersonFilterStage();
+ stage.setId("foo");
+ stage.setDesignatedTypes(CollectionSupport.setOf(ContactPersonFilterStage.ADMINISTRATIVE, ContactPersonFilterStage.OTHER));
+ stage.setKeepingTypes(false);
+ stage.initialize();
+
+ final ArrayList<Item<Element>> items = new ArrayList<>();
+ items.add(new DOMElementItem(entitiesDescriptor));
+
+ stage.execute(items);
+
+ Element filteredEntitiesDescriptor = items.get(0).unwrap();
+ List<Element> entityDescriptors = ElementSupport.getChildElements(filteredEntitiesDescriptor);
+
+ Element idpDescriptor = entityDescriptors.get(0);
+ assert idpDescriptor != null;
+ List<Element> contactPersons = ElementSupport.getChildElements(idpDescriptor, contactPersonQname);
+ Assert.assertEquals(contactPersons.size(), 1);
+
+ Element issuesDescriptor = entityDescriptors.get(1);
+ assert issuesDescriptor != null;
+ contactPersons = ElementSupport.getChildElements(issuesDescriptor, contactPersonQname);
+ Assert.assertEquals(contactPersons.size(), 3);
+
+ Element wikiDescriptor = entityDescriptors.get(2);
+ assert wikiDescriptor != null;
+ contactPersons = ElementSupport.getChildElements(wikiDescriptor, contactPersonQname);
+ Assert.assertEquals(contactPersons.size(), 0);
+ }
+
+ @Test
+ @Deprecated(forRemoval=true, since="0.10.0")
+ public void testRemovingContactPersonsLegacy() throws Exception {
final @Nonnull var entitiesDescriptor = readXMLData("entities.xml");
ContactPersonFilterStage stage = new ContactPersonFilterStage();
stage.setId("foo");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list