Class AbstractDynamicHTTPFetchingStrategy<MetadataType>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
-
- net.shibboleth.oidc.metadata.impl.AbstractDynamicHTTPFetchingStrategy<MetadataType>
-
- Type Parameters:
MetadataType- the metadata type.
- All Implemented Interfaces:
Function<CriteriaSet,MetadataType>,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
- Direct Known Subclasses:
HTTPProviderConfigurationFetchingStrategy,MetadataPolicyViaLocationFetchingStrategy
public abstract class AbstractDynamicHTTPFetchingStrategy<MetadataType> extends AbstractIdentifiableInitializableComponent implements Function<CriteriaSet,MetadataType>
Abstract strategy for fetching metadata dynamically over HTTP.
-
-
Field Summary
Fields Modifier and Type Field Description private static String[]DEFAULT_CONTENT_TYPESDefault list of supported content MIME types.private org.apache.http.client.HttpClienthttpClientHTTP Client used to pull the configuration information.private HttpClientSecurityParametershttpClientSecurityParametersHTTP client security parameters.private org.slf4j.LoggerlogClass logger.static StringMDC_ATTRIB_CURRENT_REQUEST_URIMDC attribute representing the current request URI.private org.apache.http.client.ResponseHandler<MetadataType>responseHandlerHttpClient ResponseHandler instance to use.private List<String>supportedContentTypesList of supported MIME types for use in Accept request header and validation of response Content-Type header.private StringsupportedContentTypesValueGenerated Accept request header value.private Set<MediaType>supportedMediaTypesSupportedMediaTypeinstances, constructed from thesupportedContentTypeslist.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDynamicHTTPFetchingStrategy(org.apache.http.client.HttpClient client, org.apache.http.client.ResponseHandler<MetadataType> handler)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MetadataTypeapply(CriteriaSet criteria)private org.apache.http.client.protocol.HttpClientContextbuildHttpClientContext(org.apache.http.client.methods.HttpUriRequest request)Build theHttpClientContextinstance which will be used to invoke theHttpClientrequest.private org.apache.http.client.methods.HttpUriRequestbuildHttpRequest(CriteriaSet criteria)Build an appropriate instance ofHttpUriRequestbased on the input criteria set.protected abstract StringbuildRequestURL(CriteriaSet criteria)Build the request URL based on the input criteria set.protected voiddoInitialize()List<String>getSupportedContentTypes()Get the list of supported MIME types for use in Accept request header and validation of response Content-Type header.voidsetHttpClientSecurityParameters(HttpClientSecurityParameters params)Set an instance ofHttpClientSecurityParameterswhich provides various parameters to influence the security behavior of the HttpClient instance.voidsetSupportedContentTypes(List<String> types)Set the list of supported MIME types for use in Accept request header and validation of response Content-Type header.-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent
setId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent
getId
-
-
-
-
Field Detail
-
MDC_ATTRIB_CURRENT_REQUEST_URI
public static final String MDC_ATTRIB_CURRENT_REQUEST_URI
MDC attribute representing the current request URI. Will be available during the execution of the configuredResponseHandler.
-
DEFAULT_CONTENT_TYPES
private static final String[] DEFAULT_CONTENT_TYPES
Default list of supported content MIME types.
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
httpClient
@Nonnull private final org.apache.http.client.HttpClient httpClient
HTTP Client used to pull the configuration information.
-
supportedContentTypes
@NonnullAfterInit private List<String> supportedContentTypes
List of supported MIME types for use in Accept request header and validation of response Content-Type header.
-
supportedContentTypesValue
@NonnullAfterInit private String supportedContentTypesValue
Generated Accept request header value.
-
supportedMediaTypes
@NonnullAfterInit private Set<MediaType> supportedMediaTypes
SupportedMediaTypeinstances, constructed from thesupportedContentTypeslist.
-
httpClientSecurityParameters
@Nullable private HttpClientSecurityParameters httpClientSecurityParameters
HTTP client security parameters.
-
responseHandler
@Nonnull private final org.apache.http.client.ResponseHandler<MetadataType> responseHandler
HttpClient ResponseHandler instance to use.
-
-
Constructor Detail
-
AbstractDynamicHTTPFetchingStrategy
protected AbstractDynamicHTTPFetchingStrategy(@Nonnull org.apache.http.client.HttpClient client, @Nonnull org.apache.http.client.ResponseHandler<MetadataType> handler)Constructor.- Parameters:
client- the instance ofHttpClientused to fetch remote OIDC metadatahandler- the response handler used to convert the HTTP response to the metadata type.
-
-
Method Detail
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
setHttpClientSecurityParameters
public void setHttpClientSecurityParameters(@Nullable HttpClientSecurityParameters params)Set an instance ofHttpClientSecurityParameterswhich provides various parameters to influence the security behavior of the HttpClient instance.For all TLS-related parameters, must be used in conjunction with an HttpClient instance which is configured with either:
-
a
TLSSocketFactory -
a
SecurityEnhancedTLSSocketFactorywhich wraps an instance ofTLSSocketFactory, with the latter likely configured in a "no trust" configuration. This variant is required if either a trust engine or a client TLS credential is to be used.
For convenience methods for building a
TLSSocketFactory, seeHttpClientSupport.If the appropriate TLS socket factory is not configured and a trust engine is specified, then this will result in no TLS trust evaluation being performed and a
ResolverExceptionwill ultimately be thrown.- Parameters:
params- the security parameters
-
a
-
getSupportedContentTypes
@NonnullAfterInit @NotLive @Unmodifiable public List<String> getSupportedContentTypes()
Get the list of supported MIME types for use in Accept request header and validation of response Content-Type header.- Returns:
- the supported content types
-
setSupportedContentTypes
public void setSupportedContentTypes(@Nullable List<String> types)Set the list of supported MIME types for use in Accept request header and validation of response Content-Type header. Values will be effectively lower-cased at runtime.- Parameters:
types- the new supported content types to set
-
apply
@Nullable public MetadataType apply(@Nonnull CriteriaSet criteria)
- Specified by:
applyin interfaceFunction<CriteriaSet,MetadataType>
-
buildHttpClientContext
private org.apache.http.client.protocol.HttpClientContext buildHttpClientContext(@Nonnull org.apache.http.client.methods.HttpUriRequest request)Build theHttpClientContextinstance which will be used to invoke theHttpClientrequest.- Parameters:
request- the current HTTP request- Returns:
- a new instance of
HttpClientContext
-
buildHttpRequest
@Nullable private org.apache.http.client.methods.HttpUriRequest buildHttpRequest(@Nonnull CriteriaSet criteria)Build an appropriate instance ofHttpUriRequestbased on the input criteria set.- Parameters:
criteria- the input criteria set- Returns:
- the newly constructed request, or null if it can not be built from the supplied criteria
-
buildRequestURL
@Nullable protected abstract String buildRequestURL(@Nonnull CriteriaSet criteria)
Build the request URL based on the input criteria set.- Parameters:
criteria- the input criteria set- Returns:
- the request URL, or null if it can not be built based on the supplied criteria
-
-