Class AbstractDynamicHTTPFetchingStrategy<MetadataType>

Type Parameters:
MetadataType - the metadata type.
All Implemented Interfaces:
Function<CriteriaSet,MetadataType>, Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent
Direct Known Subclasses:
HTTPProviderConfigurationFetchingStrategy, MetadataPolicyViaLocationFetchingStrategy

public abstract class AbstractDynamicHTTPFetchingStrategy<MetadataType> extends AbstractIdentifiableInitializableComponent implements Function<CriteriaSet,MetadataType>
Abstract strategy for fetching metadata dynamically over HTTP.
  • Field Details

    • 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 HttpClientResponseHandler.
    • DEFAULT_CONTENT_TYPES

      private static final String[] DEFAULT_CONTENT_TYPES
      Default list of supported content MIME types.
    • log

      @Nonnull private final org.slf4j.Logger log
      Class logger.
    • httpClient

      @Nonnull private final org.apache.hc.client5.http.classic.HttpClient httpClient
      HTTP Client used to pull the configuration information.
    • 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.
    • supportedMediaTypes

      @NonnullAfterInit private Set<MediaType> supportedMediaTypes
      Supported MediaType instances, constructed from the supportedContentTypes list.
    • httpClientSecurityParameters

      @Nullable private HttpClientSecurityParameters httpClientSecurityParameters
      HTTP client security parameters.
    • responseHandler

      @Nonnull private final org.apache.hc.core5.http.io.HttpClientResponseHandler<MetadataType> responseHandler
      HttpClient ResponseHandler instance to use.
  • Constructor Details

    • AbstractDynamicHTTPFetchingStrategy

      protected AbstractDynamicHTTPFetchingStrategy(@Nonnull org.apache.hc.client5.http.classic.HttpClient client, @Nonnull org.apache.hc.core5.http.io.HttpClientResponseHandler<MetadataType> handler)
      Constructor.
      Parameters:
      client - the instance of HttpClient used to fetch remote OIDC metadata
      handler - the response handler used to convert the HTTP response to the metadata type.
  • Method Details

    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractIdentifiedInitializableComponent
      Throws:
      ComponentInitializationException
    • setHttpClientSecurityParameters

      public void setHttpClientSecurityParameters(@Nullable 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:

      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
    • 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
    • apply

      @Nullable public MetadataType apply(@Nullable CriteriaSet criteria)
      Specified by:
      apply in interface Function<CriteriaSet,MetadataType>
    • buildHttpClientContext

      @Nonnull private org.apache.hc.client5.http.protocol.HttpClientContext buildHttpClientContext(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request)
      Build the HttpClientContext instance which will be used to invoke the HttpClient request.
      Parameters:
      request - the current HTTP request
      Returns:
      a new instance of HttpClientContext
    • buildHttpRequest

      @Nullable private org.apache.hc.core5.http.ClassicHttpRequest buildHttpRequest(@Nullable CriteriaSet criteria)
      Build an appropriate instance of ClassicHttpRequest 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(@Nullable 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