Class AbstractHTTPSearchBuilder
- All Implemented Interfaces:
ExecutableSearchBuilder<HTTPSearch>
,Component
,DestructableComponent
,InitializableComponent
- Direct Known Subclasses:
TemplatedBodyBuilder
,TemplatedURLBuilder
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
FieldsModifier and TypeFieldDescriptionMap of headers to set.private HttpClientSecurityParameters
HTTP client security parameters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild
(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Creates an executable search that can be executed against a data source in order to produce results.Get map of headers that will be set on request.Get the optional client security parameters.protected org.apache.http.client.methods.HttpUriRequest
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.http.client.methods.HttpUriRequest 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
Set the optional client security parameters.Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
-
Field Details
-
headerList
Map of headers to set. -
httpClientSecurityParameters
HTTP client security parameters.
-
-
Constructor Details
-
AbstractHTTPSearchBuilder
public AbstractHTTPSearchBuilder()Constructor.
-
-
Method Details
-
getHeaders
Get map of headers that will be set on request.- Returns:
- map of headers
-
setHeaders
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
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
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
public HTTPSearch build(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionCreates an executable search that can be executed against a data source in order to produce results.- Specified by:
build
in interfaceExecutableSearchBuilder<HTTPSearch>
- Parameters:
resolutionContext
- current request contextdependencyAttributes
- 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 ResolutionExceptionMethod to return the URL to access via GET.Subclasses may override this method to support simple GET requests.
- Parameters:
resolutionContext
- the context of the resolutiondependencyAttributes
- made available to the request- Returns:
- the URL to GET
- Throws:
ResolutionException
- if an error occurs
-
getHttpRequest
@Nonnull protected org.apache.http.client.methods.HttpUriRequest getHttpRequest(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String, List<IdPAttributeValue>> dependencyAttributes) throws ResolutionExceptionDefault implementation just supports GET and builds a request around a URL.- Parameters:
resolutionContext
- the context of the resolutiondependencyAttributes
- made available to the request- Returns:
- the
HttpRequest
to use - Throws:
ResolutionException
- if an error occurs
-
getResultCacheKey
@Nullable protected String getResultCacheKey(@Nonnull org.apache.http.client.methods.HttpUriRequest 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 executedresolutionContext
- the attribute resolution contextdependencyAttributes
- dependencies- Returns:
- the cache key
-