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 HttpClientSecurityParametersHTTP 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.hc.core5.http.ClassicHttpRequestgetHttpRequest(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Default implementation just supports GET and builds a request around a URL.protected StringgetResultCacheKey(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 StringgetURL(AttributeResolutionContext resolutionContext, Map<String, List<IdPAttributeValue>> dependencyAttributes) Method to return the URL to access via GET.voidsetHeaders(Map<String, String> headers) Set map of headers that will be set on request.voidSet 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
-
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
@Nonnull 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:
buildin 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.hc.core5.http.ClassicHttpRequest 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
ClassicHttpRequestto 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 executedresolutionContext- the attribute resolution contextdependencyAttributes- dependencies- Returns:
- the cache key
-