Class ElementsStrippingStage

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
All Implemented Interfaces:
Stage<Element>, net.shibboleth.shared.component.Component, net.shibboleth.shared.component.DestructableComponent, net.shibboleth.shared.component.IdentifiableComponent, net.shibboleth.shared.component.IdentifiedComponent, net.shibboleth.shared.component.InitializableComponent

@ThreadSafe public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsStrippingStage.Context>
A stage which removes all instances of the specified elements from DOM metadata.

The elements to be removed are specified by the combination of a namespace (as in ElementStrippingStage) and a collection of names.

The stage ignores all elements not in the specified namespace.

If an element is in the specified namespace, it is by default removed if its local name is in the specified list of names.

The default behaviour can be changed if the keeping property is set. In this case, the stage still ignores any elements not in the specified namespace, but elements within that namespace will be removed if their local names do not appear in the collection of names.

Since:
0.10.0
  • Field Details

    • elementNamespace

      @NonnullAfterInit @NotEmpty private String elementNamespace
      Namespace of the elements to strip.
    • elementNames

      @Nonnull @NonnullElements @Unmodifiable private Set<String> elementNames
      Names of the elements to strip.
    • keeping

      private boolean keeping
      Whether we are keeping the designaed elements (false by default).
  • Constructor Details

    • ElementsStrippingStage

      public ElementsStrippingStage()
  • Method Details

    • getElementNamespace

      @NonnullAfterInit @NotEmpty public final String getElementNamespace()
      Get the namespace of the elements to strip.
      Returns:
      namespace of the elements to strip
    • setElementNamespace

      public void setElementNamespace(@Nonnull @NotEmpty String namespace)
      Set the namespace of the elements to strip.
      Parameters:
      namespace - namespace of the elements to strip
    • getElementNames

      @Nonnull @NonnullElements @Unmodifiable public final Collection<String> getElementNames()
      Get the names of the elements to strip.
      Returns:
      the names of the elements to strip
    • setElementNames

      public void setElementNames(@Nonnull @NonnullElements @Unmodifiable @NotEmpty Collection<String> names)
      Set the names of the elements to strip.
      Parameters:
      names - the names of the elements to strip
    • setKeeping

      public void setKeeping(boolean keep)
      Set whether the designated elements are to be kept. The default behaviour is for the designated elements to be removed.
      Parameters:
      keep - true if the designated elements are to be keot
    • isKeeping

      public boolean isKeeping()
      Indicates whether the designated elements are being kept or removed.
      Returns:
      true if the designated elements are being kept
    • applicable

      protected boolean applicable(@Nonnull Element element, @Nonnull ElementsStrippingStage.Context context)
      Description copied from class: AbstractDOMTraversalStage
      Indicates whether the visitor should be applied to a particular Element.
      Specified by:
      applicable in class AbstractDOMTraversalStage<ElementsStrippingStage.Context>
      Parameters:
      element - Element to which we may wish to apply the visitor
      context - DOMTraversalContext implementation being used to manage the traversal
      Returns:
      true if the visitor should be applied to this Element.
    • visit

      protected void visit(@Nonnull Element element, @Nonnull ElementsStrippingStage.Context context)
      Description copied from class: AbstractDOMTraversalStage
      Visit a particular Element.
      Specified by:
      visit in class AbstractDOMTraversalStage<ElementsStrippingStage.Context>
      Parameters:
      element - the Element to visit
      context - the traversal context
    • doInitialize

      protected void doInitialize() throws net.shibboleth.shared.component.ComponentInitializationException
      Overrides:
      doInitialize in class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
      Throws:
      net.shibboleth.shared.component.ComponentInitializationException
    • buildContext

      @Nonnull protected ElementsStrippingStage.Context buildContext(@Nonnull Item<Element> item)
      Description copied from class: AbstractDOMTraversalStage
      Build the context for a particular traversal.
      Specified by:
      buildContext in class AbstractDOMTraversalStage<ElementsStrippingStage.Context>
      Parameters:
      item - the Item we are traversing
      Returns:
      an appropriate context