Class AbstractMetadataResolver

  • All Implemented Interfaces:
    net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.IdentifiedComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, net.shibboleth.utilities.java.support.resolver.Resolver<org.opensaml.saml.saml2.metadata.EntityDescriptor,​net.shibboleth.utilities.java.support.resolver.CriteriaSet>, org.opensaml.saml.metadata.resolver.MetadataResolver
    Direct Known Subclasses:
    AbstractBatchMetadataResolver, AbstractDynamicMetadataResolver

    public abstract class AbstractMetadataResolver
    extends net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
    implements org.opensaml.saml.metadata.resolver.MetadataResolver
    An abstract, base, implementation of a metadata provider.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  AbstractMetadataResolver.EntityBackingStore
      The collection of data which provides the backing store for the processed metadata.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> criterionPredicateRegistry
      Registry used in resolving predicates from criteria.
      private AbstractMetadataResolver.EntityBackingStore entityBackingStore
      Backing store for runtime EntityDescriptor data.
      private boolean failFastInitialization
      Whether problems during initialization should cause the provider to fail or go on without metadata.
      private org.slf4j.Logger log
      Class logger.
      private String logPrefix
      Logging prefix.
      private org.opensaml.saml.metadata.resolver.filter.MetadataFilter mdFilter
      Filter applied to all metadata.
      private net.shibboleth.utilities.java.support.xml.ParserPool parser
      Pool of parsers used to process XML.
      private boolean requireValidMetadata
      Whether metadata is required to be valid.
      private boolean satisfyAnyPredicates
      Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).
      private org.opensaml.core.xml.io.UnmarshallerFactory unmarshallerFactory
      Unmarshaller factory used to get an unmarshaller for the metadata DOM.
      private boolean useDefaultPredicateRegistry
      Flag which determines whether the default predicate registry will be used if one is not supplied explicitly.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected AbstractMetadataResolver.EntityBackingStore createNewBackingStore()
      Create a new backing store instance for EntityDescriptor data.
      protected void doDestroy()
      protected void doInitialize()
      protected org.opensaml.core.xml.XMLObject filterMetadata​(org.opensaml.core.xml.XMLObject metadata)
      Filters the given metadata.
      protected AbstractMetadataResolver.EntityBackingStore getBackingStore()
      Get the EntityDescriptor backing store currently in use by the metadata resolver.
      net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> getCriterionPredicateRegistry()
      Get the registry used in resolving predicates from criteria.
      protected String getLogPrefix()
      Return a prefix for logging messages for this component.
      org.opensaml.saml.metadata.resolver.filter.MetadataFilter getMetadataFilter()
      net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
      Gets the pool of parsers to use to parse XML.
      protected org.opensaml.core.xml.io.UnmarshallerFactory getUnmarshallerFactory()
      Get the XMLObject unmarshaller factory to use.
      protected void indexEntityDescriptor​(org.opensaml.saml.saml2.metadata.EntityDescriptor entityDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore)
      Index the specified entity descriptor, updating the specified entity backing store instance as necessary.
      protected void initMetadataResolver()
      Subclasses should override this method to perform any initialization logic necessary.
      boolean isFailFastInitialization()
      Gets whether problems during initialization should cause the provider to fail or go on without metadata.
      boolean isRequireValidMetadata()
      boolean isSatisfyAnyPredicates()
      Get the flag indicating whether resolved credentials may satisfy any predicates (i.e.
      boolean isUseDefaultPredicateRegistry()
      Get the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.
      protected boolean isValid​(org.opensaml.core.xml.XMLObject descriptor)
      Returns whether the given descriptor is valid.
      protected List<org.opensaml.saml.saml2.metadata.EntityDescriptor> lookupEntityID​(String entityID)
      Get list of descriptors matching an entityID.
      protected List<org.opensaml.saml.saml2.metadata.EntityDescriptor> lookupIndexedEntityID​(String entityID)
      Lookup the specified entityID from the index.
      protected org.opensaml.saml.metadata.resolver.filter.MetadataFilterContext newFilterContext()
      Get a new instance of MetadataFilterContext to be used when filtering metadata.
      protected Iterable<org.opensaml.saml.saml2.metadata.EntityDescriptor> predicateFilterCandidates​(Iterable<org.opensaml.saml.saml2.metadata.EntityDescriptor> candidates, net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria, boolean onEmptyPredicatesReturnEmpty)
      Filter the supplied candidates by resolving predicates from the supplied criteria and applying the predicates to return a filtered Iterable.
      protected void preProcessEntitiesDescriptor​(org.opensaml.saml.saml2.metadata.EntitiesDescriptor entitiesDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore)
      Pre-process the specified entities descriptor, updating the specified entity backing store instance as necessary.
      protected void preProcessEntityDescriptor​(org.opensaml.saml.saml2.metadata.EntityDescriptor entityDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore)
      Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.
      protected void releaseMetadataDOM​(org.opensaml.core.xml.XMLObject metadata)
      Releases the DOM representation from the metadata object.
      protected void removeByEntityID​(String entityID, AbstractMetadataResolver.EntityBackingStore backingStore)
      Remove from the backing store all metadata for the entity with the given entity ID.
      org.opensaml.saml.saml2.metadata.EntityDescriptor resolveSingle​(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
      protected void setBackingStore​(AbstractMetadataResolver.EntityBackingStore newBackingStore)
      Set the EntityDescriptor backing store currently in use by the metadata resolver.
      void setCriterionPredicateRegistry​(net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> registry)
      Set the registry used in resolving predicates from criteria.
      void setFailFastInitialization​(boolean failFast)
      Sets whether problems during initialization should cause the provider to fail or go on without metadata.
      void setMetadataFilter​(org.opensaml.saml.metadata.resolver.filter.MetadataFilter newFilter)
      void setParserPool​(net.shibboleth.utilities.java.support.xml.ParserPool pool)
      Sets the pool of parsers to use to parse XML.
      void setRequireValidMetadata​(boolean require)
      void setSatisfyAnyPredicates​(boolean flag)
      Set the flag indicating whether resolved credentials may satisfy any predicates (i.e.
      void setUseDefaultPredicateRegistry​(boolean flag)
      Set the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.
      protected org.opensaml.core.xml.XMLObject unmarshallMetadata​(InputStream metadataInput)
      Unmarshalls the metadata from the given stream.
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent

        setId
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent

        getId
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent

        destroy, initialize, isDestroyed, isInitialized
      • Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent

        getId
      • Methods inherited from interface net.shibboleth.utilities.java.support.resolver.Resolver

        resolve
    • Field Detail

      • log

        private final org.slf4j.Logger log
        Class logger.
      • unmarshallerFactory

        private org.opensaml.core.xml.io.UnmarshallerFactory unmarshallerFactory
        Unmarshaller factory used to get an unmarshaller for the metadata DOM.
      • requireValidMetadata

        private boolean requireValidMetadata
        Whether metadata is required to be valid.
      • mdFilter

        private org.opensaml.saml.metadata.resolver.filter.MetadataFilter mdFilter
        Filter applied to all metadata.
      • logPrefix

        private String logPrefix
        Logging prefix.
      • failFastInitialization

        private boolean failFastInitialization
        Whether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future. Default: true.
      • parser

        private net.shibboleth.utilities.java.support.xml.ParserPool parser
        Pool of parsers used to process XML.
      • satisfyAnyPredicates

        private boolean satisfyAnyPredicates
        Flag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false). Defaults to false.
      • criterionPredicateRegistry

        private net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> criterionPredicateRegistry
        Registry used in resolving predicates from criteria.
      • useDefaultPredicateRegistry

        private boolean useDefaultPredicateRegistry
        Flag which determines whether the default predicate registry will be used if one is not supplied explicitly. Defaults to true.
    • Constructor Detail

      • AbstractMetadataResolver

        public AbstractMetadataResolver()
        Constructor.
    • Method Detail

      • isRequireValidMetadata

        public boolean isRequireValidMetadata()
        Specified by:
        isRequireValidMetadata in interface org.opensaml.saml.metadata.resolver.MetadataResolver
      • setRequireValidMetadata

        public void setRequireValidMetadata​(boolean require)
        Specified by:
        setRequireValidMetadata in interface org.opensaml.saml.metadata.resolver.MetadataResolver
      • getMetadataFilter

        @Nullable
        public org.opensaml.saml.metadata.resolver.filter.MetadataFilter getMetadataFilter()
        Specified by:
        getMetadataFilter in interface org.opensaml.saml.metadata.resolver.MetadataResolver
      • setMetadataFilter

        public void setMetadataFilter​(@Nullable
                                      org.opensaml.saml.metadata.resolver.filter.MetadataFilter newFilter)
        Specified by:
        setMetadataFilter in interface org.opensaml.saml.metadata.resolver.MetadataResolver
      • isFailFastInitialization

        public boolean isFailFastInitialization()
        Gets whether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future.
        Returns:
        whether problems during initialization should cause the provider to fail
      • setFailFastInitialization

        public void setFailFastInitialization​(boolean failFast)
        Sets whether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future.
        Parameters:
        failFast - whether problems during initialization should cause the provider to fail
      • getParserPool

        @Nonnull
        public net.shibboleth.utilities.java.support.xml.ParserPool getParserPool()
        Gets the pool of parsers to use to parse XML.
        Returns:
        pool of parsers to use to parse XML
      • setParserPool

        public void setParserPool​(@Nonnull
                                  net.shibboleth.utilities.java.support.xml.ParserPool pool)
        Sets the pool of parsers to use to parse XML.
        Parameters:
        pool - pool of parsers to use to parse XML
      • isSatisfyAnyPredicates

        public boolean isSatisfyAnyPredicates()
        Get the flag indicating whether resolved credentials may satisfy any predicates (i.e. connected by logical 'OR') or all predicates (connected by logical 'AND').

        Defaults to false.

        Returns:
        true if must satisfy all, false otherwise
      • setSatisfyAnyPredicates

        public void setSatisfyAnyPredicates​(boolean flag)
        Set the flag indicating whether resolved credentials may satisfy any predicates (i.e. connected by logical 'OR') or all predicates (connected by logical 'AND').

        Defaults to false.

        Parameters:
        flag - true if must satisfy all, false otherwise
      • getCriterionPredicateRegistry

        @NonnullAfterInit
        public net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> getCriterionPredicateRegistry()
        Get the registry used in resolving predicates from criteria.
        Returns:
        the effective registry instance used
      • setCriterionPredicateRegistry

        public void setCriterionPredicateRegistry​(@Nullable
                                                  net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<org.opensaml.saml.saml2.metadata.EntityDescriptor> registry)
        Set the registry used in resolving predicates from criteria.
        Parameters:
        registry - the registry instance to use
      • isUseDefaultPredicateRegistry

        public boolean isUseDefaultPredicateRegistry()
        Get the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.

        Defaults to true.

        Returns:
        true if should use default registry, false otherwise
      • setUseDefaultPredicateRegistry

        public void setUseDefaultPredicateRegistry​(boolean flag)
        Set the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.

        Defaults to true.

        Parameters:
        flag - true if should use default registry, false otherwise
      • resolveSingle

        @Nullable
        public org.opensaml.saml.saml2.metadata.EntityDescriptor resolveSingle​(net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
                                                                        throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Specified by:
        resolveSingle in interface net.shibboleth.utilities.java.support.resolver.Resolver<org.opensaml.saml.saml2.metadata.EntityDescriptor,​net.shibboleth.utilities.java.support.resolver.CriteriaSet>
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException
      • getUnmarshallerFactory

        protected org.opensaml.core.xml.io.UnmarshallerFactory getUnmarshallerFactory()
        Get the XMLObject unmarshaller factory to use.
        Returns:
        the unmarshaller factory instance to use
      • doInitialize

        protected final void doInitialize()
                                   throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • doDestroy

        protected void doDestroy()
        Overrides:
        doDestroy in class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
      • initMetadataResolver

        protected void initMetadataResolver()
                                     throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Subclasses should override this method to perform any initialization logic necessary. Default implementation is a no-op.
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException - thrown if there is a problem initializing the provider
      • unmarshallMetadata

        @Nonnull
        protected org.opensaml.core.xml.XMLObject unmarshallMetadata​(@Nonnull
                                                                     InputStream metadataInput)
                                                              throws org.opensaml.core.xml.io.UnmarshallingException
        Unmarshalls the metadata from the given stream. The stream is closed by this method and the returned metadata released its DOM representation.
        Parameters:
        metadataInput - the input reader to the metadata.
        Returns:
        the unmarshalled metadata
        Throws:
        org.opensaml.core.xml.io.UnmarshallingException - thrown if the metadata can no be unmarshalled
      • filterMetadata

        @Nullable
        protected org.opensaml.core.xml.XMLObject filterMetadata​(@Nullable
                                                                 org.opensaml.core.xml.XMLObject metadata)
                                                          throws org.opensaml.saml.metadata.resolver.filter.FilterException
        Filters the given metadata.
        Parameters:
        metadata - the metadata to be filtered
        Returns:
        the filtered metadata
        Throws:
        org.opensaml.saml.metadata.resolver.filter.FilterException - thrown if there is an error filtering the metadata
      • newFilterContext

        @Nonnull
        protected org.opensaml.saml.metadata.resolver.filter.MetadataFilterContext newFilterContext()
        Get a new instance of MetadataFilterContext to be used when filtering metadata.

        This default implementation will just return an empty context. Subclasses would override to add contextual info specific to the implementation.

        Returns:
        the new filter context instance
      • releaseMetadataDOM

        protected void releaseMetadataDOM​(@Nullable
                                          org.opensaml.core.xml.XMLObject metadata)
        Releases the DOM representation from the metadata object.
        Parameters:
        metadata - the metadata object
      • isValid

        protected boolean isValid​(@Nullable
                                  org.opensaml.core.xml.XMLObject descriptor)
        Returns whether the given descriptor is valid. If valid metadata is not required this method always returns true.
        Parameters:
        descriptor - the descriptor to check
        Returns:
        true if valid metadata is not required or the given descriptor is valid, false otherwise
      • lookupEntityID

        @Nonnull
        @NonnullElements
        protected List<org.opensaml.saml.saml2.metadata.EntityDescriptor> lookupEntityID​(@Nonnull @NotEmpty
                                                                                         String entityID)
                                                                                  throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Get list of descriptors matching an entityID.
        Parameters:
        entityID - entityID to lookup
        Returns:
        a list of descriptors
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException - if an error occurs
      • lookupIndexedEntityID

        @Nonnull
        @NonnullElements
        protected List<org.opensaml.saml.saml2.metadata.EntityDescriptor> lookupIndexedEntityID​(@Nonnull @NotEmpty
                                                                                                String entityID)
        Lookup the specified entityID from the index. The returned list will be a copy of what is stored in the backing index, and is safe to be manipulated by callers.
        Parameters:
        entityID - the entityID to lookup
        Returns:
        list copy of indexed entityID's, may be empty, will never be null
      • createNewBackingStore

        @Nonnull
        protected AbstractMetadataResolver.EntityBackingStore createNewBackingStore()
        Create a new backing store instance for EntityDescriptor data. Subclasses may override to return a more specialized subclass type. Note this method does not make the returned backing store the effective one in use. The caller is responsible for calling setBackingStore(EntityBackingStore) to make it the effective instance in use.
        Returns:
        the new backing store instance
      • getBackingStore

        @Nonnull
        protected AbstractMetadataResolver.EntityBackingStore getBackingStore()
        Get the EntityDescriptor backing store currently in use by the metadata resolver.
        Returns:
        the current effective entity backing store
      • setBackingStore

        protected void setBackingStore​(@Nonnull
                                       AbstractMetadataResolver.EntityBackingStore newBackingStore)
        Set the EntityDescriptor backing store currently in use by the metadata resolver.
        Parameters:
        newBackingStore - the new entity backing store
      • preProcessEntityDescriptor

        protected void preProcessEntityDescriptor​(@Nonnull
                                                  org.opensaml.saml.saml2.metadata.EntityDescriptor entityDescriptor,
                                                  @Nonnull
                                                  AbstractMetadataResolver.EntityBackingStore backingStore)
        Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.
        Parameters:
        entityDescriptor - the target entity descriptor to process
        backingStore - the backing store instance to update
      • removeByEntityID

        protected void removeByEntityID​(@Nonnull
                                        String entityID,
                                        @Nonnull
                                        AbstractMetadataResolver.EntityBackingStore backingStore)
        Remove from the backing store all metadata for the entity with the given entity ID.
        Parameters:
        entityID - the entity ID of the metadata to remove
        backingStore - the backing store instance to update
      • indexEntityDescriptor

        protected void indexEntityDescriptor​(@Nonnull
                                             org.opensaml.saml.saml2.metadata.EntityDescriptor entityDescriptor,
                                             @Nonnull
                                             AbstractMetadataResolver.EntityBackingStore backingStore)
        Index the specified entity descriptor, updating the specified entity backing store instance as necessary.
        Parameters:
        entityDescriptor - the target entity descriptor to process
        backingStore - the backing store instance to update
      • preProcessEntitiesDescriptor

        protected void preProcessEntitiesDescriptor​(@Nonnull
                                                    org.opensaml.saml.saml2.metadata.EntitiesDescriptor entitiesDescriptor,
                                                    AbstractMetadataResolver.EntityBackingStore backingStore)
        Pre-process the specified entities descriptor, updating the specified entity backing store instance as necessary.
        Parameters:
        entitiesDescriptor - the target entities descriptor to process
        backingStore - the backing store instance to update
      • predicateFilterCandidates

        protected Iterable<org.opensaml.saml.saml2.metadata.EntityDescriptor> predicateFilterCandidates​(@Nonnull
                                                                                                        Iterable<org.opensaml.saml.saml2.metadata.EntityDescriptor> candidates,
                                                                                                        @Nonnull
                                                                                                        net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria,
                                                                                                        boolean onEmptyPredicatesReturnEmpty)
                                                                                                 throws net.shibboleth.utilities.java.support.resolver.ResolverException
        Filter the supplied candidates by resolving predicates from the supplied criteria and applying the predicates to return a filtered Iterable.
        Parameters:
        candidates - the candidates to evaluate
        criteria - the criteria set to evaluate
        onEmptyPredicatesReturnEmpty - if true and no predicates are supplied, then return an empty iterable; otherwise return the original input candidates
        Returns:
        an iterable of the candidates filtered by the resolved predicates
        Throws:
        net.shibboleth.utilities.java.support.resolver.ResolverException - if there is a fatal error during resolution
      • getLogPrefix

        @Nonnull
        @NotEmpty
        protected String getLogPrefix()
        Return a prefix for logging messages for this component.
        Returns:
        a string for insertion at the beginning of any log messages