[java-metadata-aggregator COMMIT] in /trunk/aggregator-pipeline/src: main/java/net/shibboleth/metadata/dom/saml/Remov...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Mar 23 14:10:22 GMT 2012
Author: lajoie
Date: Fri Mar 23 14:10:21 2012
New Revision: 200
URL: http://svn.shibboleth.net/view/java-metadata-aggregator?rev=200&view=rev
Log:
Have RemoveContactPerson remove contacts by type - MDA-41
Add helped method to unit test base class to read data files from class-named directories
Added:
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage/
trunk/aggregator-pipeline/src/test/resources/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage/entitiesDescriptor.xml (with props)
Modified:
trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage.java
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/BaseDomTest.java
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/ElementFormattingStageTest.java
trunk/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStageTest.java
Modified: trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage.java
URL: http://svn.shibboleth.net/view/java-metadata-aggregator/trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage.java?rev=200&r1=199&r2=200&view=diff
==============================================================================
--- trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage.java (original)
+++ trunk/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/RemoveContactPersonStage.java Fri Mar 23 14:10:21 2012
@@ -17,26 +17,140 @@
package net.shibboleth.metadata.dom.saml;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.dom.DomElementItem;
import net.shibboleth.metadata.pipeline.BaseIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
+import net.shibboleth.utilities.java.support.component.ComponentSupport;
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import net.shibboleth.utilities.java.support.xml.AttributeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
+import net.shibboleth.utilities.java.support.xml.SerializeSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
-/** Filtering stage that removes ContactPerson elements from EntityDescriptors. */
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Filtering stage that removes ContactPerson elements from EntityDescriptors.
+ *
+ * <p>
+ * 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.
+ * </p>
+ */
@ThreadSafe
public class RemoveContactPersonStage extends BaseIteratingStage<DomElementItem> {
+ /** 'technical' person type constant. */
+ public static final String TECHNICAL = "technical";
+
+ /** 'support' person type constant. */
+ public static final String SUPPORT = "support";
+
+ /** 'administrative' person type constant. */
+ public static final String ADMINISTRATIVE = "administrative";
+
+ /** 'billing' person type constant. */
+ public static final String BILLING = "billing";
+
+ /** 'other' person type constant. */
+ public static final String OTHER = "other";
+
/** Class logger. */
private final Logger log = LoggerFactory.getLogger(RemoveContactPersonStage.class);
+
+ /** Allowed contact person types. */
+ private Set<String> allowedTypes = ImmutableSet.copyOf(new String[] {TECHNICAL, SUPPORT, ADMINISTRATIVE, BILLING,
+ OTHER});
+
+ /** Person types which are white/black listed depending on the value of {@link #whitelistingTypes}. */
+ private Set<String> designatedTypes = ImmutableSet.copyOf(allowedTypes);
+
+ /** Whether {@link #designatedType} should be considered a whitelist. Default value: true */
+ private boolean whitelistingTypes = true;
+
+ /**
+ * Gets the list of designated person types.
+ *
+ * @return list of designated person types
+ */
+ @Nonnull @NonnullElements @Unmodifiable public Collection<String> getDesignateTypes() {
[... 438 lines stripped ...]
More information about the commits
mailing list