Class PredicateFilter

  • All Implemented Interfaces:
    org.opensaml.saml.metadata.resolver.filter.MetadataFilter

    public class PredicateFilter
    extends Object
    implements org.opensaml.saml.metadata.resolver.filter.MetadataFilter
    A filter that removes any EntityDescriptor that does or does not match a Predicate, thus a whitelist or blacklist.

    If an EntitiesDescriptor does not contain any children after filtering it may, optionally, be removed as well. If the root element of the metadata document is an @link EntitiesDescriptor}, it will never be removed, regardless of of whether it still has children.

    • Field Detail

      • log

        @Nonnull
        private final Logger log
        Class logger.
      • direction

        @Nonnull
        private final PredicateFilter.Direction direction
        Whether matching means to include or exclude an entity.
      • condition

        @Nonnull
        private final Predicate<org.opensaml.saml.saml2.metadata.EntityDescriptor> condition
        Matching predicate.
      • removeEmptyEntitiesDescriptors

        private boolean removeEmptyEntitiesDescriptors
        Whether to keep entities descriptors that contain no entity descriptors; default value: true.
    • Constructor Detail

      • PredicateFilter

        public PredicateFilter​(@Nonnull
                               PredicateFilter.Direction dir,
                               @Nonnull
                               Predicate<org.opensaml.saml.saml2.metadata.EntityDescriptor> theCondition)
        Constructor.
        Parameters:
        dir - whether to whitelist or blacklist
        theCondition - the predicate to apply to determine inclusion or exclusion
    • Method Detail

      • getDirection

        @Nonnull
        public PredicateFilter.Direction getDirection()
        Get the direction of filtering.
        Returns:
        filtering direction
      • getCondition

        @Nonnull
        public Predicate<org.opensaml.saml.saml2.metadata.EntityDescriptor> getCondition()
        Get the predicate to be applied.
        Returns:
        the predicate to be applied
      • getRemoveEmptyEntitiesDescriptors

        public boolean getRemoveEmptyEntitiesDescriptors()
        Get whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.
        Returns:
        whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors
      • setRemoveEmptyEntitiesDescriptors

        public void setRemoveEmptyEntitiesDescriptors​(boolean remove)
        Set whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.
        Parameters:
        remove - whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors
      • filter

        public org.opensaml.core.xml.XMLObject filter​(@Nullable
                                                      org.opensaml.core.xml.XMLObject metadata,
                                                      @Nonnull
                                                      org.opensaml.saml.metadata.resolver.filter.MetadataFilterContext context)
                                               throws org.opensaml.saml.metadata.resolver.filter.FilterException
        Specified by:
        filter in interface org.opensaml.saml.metadata.resolver.filter.MetadataFilter
        Throws:
        org.opensaml.saml.metadata.resolver.filter.FilterException
      • filterEntitiesDescriptor

        protected void filterEntitiesDescriptor​(@Nonnull
                                                org.opensaml.saml.saml2.metadata.EntitiesDescriptor descriptor)
        Filters entities descriptor.
        Parameters:
        descriptor - entities descriptor to filter