Class AbstractDynamicHTTPMetadataResolver

  • 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.ClearableMetadataResolver, org.opensaml.saml.metadata.resolver.DynamicMetadataResolver, org.opensaml.saml.metadata.resolver.MetadataResolver
    Direct Known Subclasses:
    FunctionDrivenDynamicHTTPMetadataResolver

    public abstract class AbstractDynamicHTTPMetadataResolver
    extends AbstractDynamicMetadataResolver
    Abstract subclass for dynamic metadata resolvers that implement metadata resolution based on HTTP requests.
    • Field Detail

      • DEFAULT_CONTENT_TYPES

        public static final String[] DEFAULT_CONTENT_TYPES
        Default list of supported content MIME types.
      • MDC_ATTRIB_CURRENT_REQUEST_URI

        public static final String MDC_ATTRIB_CURRENT_REQUEST_URI
        MDC attribute representing the current request URI. Will be available during the execution of the configured ResponseHandler.
      • log

        @Nonnull
        private final Logger log
        Class logger.
      • httpClient

        @Nonnull
        private HttpClient httpClient
        HTTP Client used to pull the metadata.
      • supportedContentTypes

        @NonnullAfterInit
        private List<String> supportedContentTypes
        List of supported MIME types for use in Accept request header and validation of response Content-Type header.
      • supportedContentTypesValue

        @NonnullAfterInit
        private String supportedContentTypesValue
        Generated Accept request header value.
      • responseHandler

        @Nonnull
        private ResponseHandler<org.opensaml.core.xml.XMLObject> responseHandler
        HttpClient ResponseHandler instance to use.
      • httpClientSecurityParameters

        @Nullable
        private org.opensaml.security.httpclient.HttpClientSecurityParameters httpClientSecurityParameters
        Optional HttpClient security parameters.
    • Constructor Detail

      • AbstractDynamicHTTPMetadataResolver

        public AbstractDynamicHTTPMetadataResolver​(@Nonnull
                                                   HttpClient client)
        Constructor.
        Parameters:
        client - the instance of HttpClient used to fetch remote metadata
      • AbstractDynamicHTTPMetadataResolver

        public AbstractDynamicHTTPMetadataResolver​(@Nullable
                                                   Timer backgroundTaskTimer,
                                                   @Nonnull
                                                   HttpClient client)
        Constructor.
        Parameters:
        backgroundTaskTimer - the Timer instance used to run resolver background managment tasks
        client - the instance of HttpClient used to fetch remote metadata
    • Method Detail

      • getHttpClientSecurityParameters

        @Nullable
        protected org.opensaml.security.httpclient.HttpClientSecurityParameters getHttpClientSecurityParameters()
        Get the instance of HttpClientSecurityParameters which provides various parameters to influence the security behavior of the HttpClient instance.
        Returns:
        the parameters instance, or null
      • setHttpClientSecurityParameters

        public void setHttpClientSecurityParameters​(@Nullable
                                                    org.opensaml.security.httpclient.HttpClientSecurityParameters params)
        Set an instance of HttpClientSecurityParameters which provides various parameters to influence the security behavior of the HttpClient instance.

        For all TLS-related parameters, must be used in conjunction with an HttpClient instance which is configured with either:

        • a TLSSocketFactory
        • a SecurityEnhancedTLSSocketFactory which wraps an instance of TLSSocketFactory, with the latter likely configured in a "no trust" configuration. This variant is required if either a trust engine or a client TLS credential is to be used.

        For convenience methods for building a TLSSocketFactory, see HttpClientSupport.

        If the appropriate TLS socket factory is not configured and a trust engine is specified, then this will result in no TLS trust evaluation being performed and a ResolverException will ultimately be thrown.

        Parameters:
        params - the security parameters
      • getSupportedMediaTypes

        @NonnullAfterInit
        @NotLive
        @Unmodifiable
        protected Set<MediaType> getSupportedMediaTypes()
        Get the list of supported MIME MediaType instances used in validation of the response Content-Type header.

        Is generated at init time from getSupportedContentTypes().

        Returns:
        the supported content types
      • getSupportedContentTypes

        @NonnullAfterInit
        @NotLive
        @Unmodifiable
        public List<String> getSupportedContentTypes()
        Get the list of supported MIME types for use in Accept request header and validation of response Content-Type header.
        Returns:
        the supported content types
      • setSupportedContentTypes

        public void setSupportedContentTypes​(@Nullable
                                             List<String> types)
        Set the list of supported MIME types for use in Accept request header and validation of response Content-Type header. Values will be effectively lower-cased at runtime.
        Parameters:
        types - the new supported content types to set
      • 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.
        Overrides:
        initMetadataResolver in class AbstractDynamicMetadataResolver
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException - thrown if there is a problem initializing the provider
      • fetchFromOriginSource

        @Nullable
        protected org.opensaml.core.xml.XMLObject fetchFromOriginSource​(@Nonnull
                                                                        net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
                                                                 throws IOException
        Fetch the metadata from the origin source.
        Specified by:
        fetchFromOriginSource in class AbstractDynamicMetadataResolver
        Parameters:
        criteria - the input criteria set
        Returns:
        the resolved metadata root XMLObject, or null if metadata could not be fetched
        Throws:
        IOException - if there is a fatal error fetching metadata from the origin source
      • buildHttpRequest

        @Nullable
        protected HttpUriRequest buildHttpRequest​(@Nonnull
                                                  net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
        Build an appropriate instance of HttpUriRequest based on the input criteria set.
        Parameters:
        criteria - the input criteria set
        Returns:
        the newly constructed request, or null if it can not be built from the supplied criteria
      • buildRequestURL

        @Nullable
        protected abstract String buildRequestURL​(@Nonnull
                                                  net.shibboleth.utilities.java.support.resolver.CriteriaSet criteria)
        Build the request URL based on the input criteria set.
        Parameters:
        criteria - the input criteria set
        Returns:
        the request URL, or null if it can not be built based on the supplied criteria