Class AbstractHTTPSearchBuilder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.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>>headerListMap of headers to set.private HttpClientSecurityParametershttpClientSecurityParametersHTTP client security parameters.
-
Constructor Summary
Constructors Constructor Description AbstractHTTPSearchBuilder()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HTTPSearchbuild(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)List<Pair<String,String>>getHeaders()Get map of headers that will be set on request.HttpClientSecurityParametersgetHttpClientSecurityParameters()Get the optional client security parameters.protected org.apache.http.client.methods.HttpUriRequestgetHttpRequest(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)Default implementation just supports GET and builds a request around a URL.protected StringgetResultCacheKey(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 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.voidsetHttpClientSecurityParameters(HttpClientSecurityParameters params)Set the optional client security parameters.-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
-
-
-
-
Field Detail
-
headerList
@Nonnull @NonnullElements @Unmodifiable private List<Pair<String,String>> headerList
Map of headers to set.
-
httpClientSecurityParameters
@Nullable private HttpClientSecurityParameters httpClientSecurityParameters
HTTP client security parameters.
-
-
Method Detail
-
getHeaders
@Nonnull @NonnullElements @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 @NonnullElements 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
public HTTPSearch build(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
- Specified by:
buildin interfaceExecutableSearchBuilder<HTTPSearch>- Throws:
ResolutionException
-
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 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
HttpRequestto 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
-
-