Class AbstractHTTPSearchBuilder

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.idp.attribute.resolver.dc.http.impl.AbstractHTTPSearchBuilder
All Implemented Interfaces:
ExecutableSearchBuilder<HTTPSearch>, Component, DestructableComponent, InitializableComponent
Direct Known Subclasses:
TemplatedBodyBuilder, TemplatedURLBuilder

public abstract class AbstractHTTPSearchBuilder extends AbstractInitializableComponent implements ExecutableSearchBuilder<HTTPSearch>
Basis of request builder. Derived classes just have to provide the per request URI but may override the complete request build if desired, for example to construct a SOAP message or something more exotic.

This is all a bit byzantine to maintain a consistent design with the LDAP/etc. connectors, which split the work of producing "search objects that execute and return a result" and "mapping strategies that process a result". The HTTP client supports response handlers that offload all the connection cleanup and avoid any extra data buffering, so our facade passes the mapping strategy in as a response handler and just returns the result.

  • Field Details

  • Constructor Details

    • AbstractHTTPSearchBuilder

      public AbstractHTTPSearchBuilder()
      Constructor.
  • Method Details

    • getHeaders

      @Nonnull @NotLive @Unmodifiable public List<Pair<String,String>> getHeaders()
      Get map of headers that will be set on request.
      Returns:
      map of headers
    • setHeaders

      public void setHeaders(@Nonnull Map<String,String> headers)
      Set map of headers that will be set on request.

      These will be *set*, so replacing any existing headers and not allowing multiple.

      Parameters:
      headers - map of headers
    • getHttpClientSecurityParameters

      @Nullable public HttpClientSecurityParameters getHttpClientSecurityParameters()
      Get the optional client security parameters.

      This is informational to accommodate a scenario in which the parameters should influence the construction of the request, but the actual parameters to use will be supplied to the HTTPSearch.execute(HttpClient, HttpClientSecurityParameters, HTTPResponseMappingStrategy) method.

      Returns:
      client security parameters
    • setHttpClientSecurityParameters

      public void setHttpClientSecurityParameters(@Nullable HttpClientSecurityParameters params)
      Set the optional client security parameters.

      This is informational to accommodate a scenario in which the parameters should influence the construction of the request, but the actual parameters to use will be supplied to the HTTPSearch.execute(HttpClient, HttpClientSecurityParameters, HTTPResponseMappingStrategy) method.

      Parameters:
      params - client security parameters
    • build

      @Nonnull public HTTPSearch build(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
      Creates an executable search that can be executed against a data source in order to produce results.
      Specified by:
      build in interface ExecutableSearchBuilder<HTTPSearch>
      Parameters:
      resolutionContext - current request context
      dependencyAttributes - made available to the executable search
      Returns:
      executable search
      Throws:
      ResolutionException - throw if their is a problem creating the executable search
    • getURL

      @Nonnull @NotEmpty protected String getURL(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
      Method to return the URL to access via GET.

      Subclasses may override this method to support simple GET requests.

      Parameters:
      resolutionContext - the context of the resolution
      dependencyAttributes - made available to the request
      Returns:
      the URL to GET
      Throws:
      ResolutionException - if an error occurs
    • getHttpRequest

      @Nonnull protected org.apache.hc.core5.http.ClassicHttpRequest getHttpRequest(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
      Default implementation just supports GET and builds a request around a URL.
      Parameters:
      resolutionContext - the context of the resolution
      dependencyAttributes - made available to the request
      Returns:
      the ClassicHttpRequest to use
      Throws:
      ResolutionException - if an error occurs
    • getResultCacheKey

      @Nullable protected String getResultCacheKey(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request, @Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes)
      Default implementation just allows caching of GET requests and returns the URI itself.
      Parameters:
      request - the HTTP request about to be executed
      resolutionContext - the attribute resolution context
      dependencyAttributes - dependencies
      Returns:
      the cache key