Package net.shibboleth.idp.attribute.resolver.dc.http.impl

# 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 Summary

Fields
Modifier and Type
Field
Description
`private List<Pair<String,String>>`
`headerList`
Map of headers to set.
`private HttpClientSecurityParameters`
`httpClientSecurityParameters`
HTTP client security parameters.

## Constructor Summary

Constructors
Constructor
Description
`AbstractHTTPSearchBuilder()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`HTTPSearch`
`build(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)`
Creates an executable search that can be executed against a data source in order to produce results.
`List<Pair<String,String>>`
`getHeaders()`
Get map of headers that will be set on request.
`HttpClientSecurityParameters`
`getHttpClientSecurityParameters()`
Get the optional client security parameters.
`protected org.apache.hc.core5.http.ClassicHttpRequest`
`getHttpRequest(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)`
Default implementation just supports GET and builds a request around a URL.
`protected String`
`getResultCacheKey(org.apache.hc.core5.http.ClassicHttpRequest request, AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)`
Default implementation just allows caching of GET requests and returns the URI itself.
`protected String`
`getURL(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)`
Method to return the URL to access via GET.
`void`
`setHeaders(Map<String,String> headers)`
Set map of headers that will be set on request.
`void`
`setHttpClientSecurityParameters(HttpClientSecurityParameters params)`
Set the optional client security parameters.

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### headerList

@Nonnull @Unmodifiable private List<Pair<String,String>> headerList
Map of headers to set.

### httpClientSecurityParameters

@Nullable private HttpClientSecurityParameters httpClientSecurityParameters
HTTP client security parameters.

## 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