Package org.opensaml.saml.metadata.resolver.impl

# Class AbstractDynamicHTTPMetadataResolver

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver
org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver
org.opensaml.saml.metadata.resolver.impl.AbstractDynamicHTTPMetadataResolver

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `Resolver<EntityDescriptor,CriteriaSet>`, `ClearableMetadataResolver`, `DynamicMetadataResolver`, `MetadataResolver`

Direct Known Subclasses:
  `FunctionDrivenDynamicHTTPMetadataResolver`

public abstract class AbstractDynamicHTTPMetadataResolver extends AbstractDynamicMetadataResolver
Abstract subclass for dynamic metadata resolvers that implement metadata resolution based on HTTP requests.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`AbstractDynamicHTTPMetadataResolver.BasicMetadataResponseHandler`
Basic HttpClient response handler for processing metadata fetch requests.

## Nested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver

`AbstractDynamicMetadataResolver.BackingStoreCleanupSweeper, AbstractDynamicMetadataResolver.DefaultCacheKeyGenerator, AbstractDynamicMetadataResolver.DynamicEntityBackingStore, AbstractDynamicMetadataResolver.EntityManagementData, AbstractDynamicMetadataResolver.PersistentCacheInitializationMetrics`

## Nested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver

`AbstractMetadataResolver.EntityBackingStore`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String[]`
`DEFAULT_CONTENT_TYPES`
Default list of supported content MIME types.
`private org.apache.hc.client5.http.classic.HttpClient`
`httpClient`
HTTP Client used to pull the metadata.
`private HttpClientSecurityParameters`
`httpClientSecurityParameters`
Optional HttpClient security parameters.
`private final org.slf4j.Logger`
`log`
Class logger.
`static final String`
`MDC_ATTRIB_CURRENT_REQUEST_URI`
MDC attribute representing the current request URI.
`private org.apache.hc.core5.http.io.HttpClientResponseHandler<XMLObject>`
`responseHandler`
HttpClient ResponseHandler instance to use.
`private List<String>`
`supportedContentTypes`
List of supported MIME types for use in Accept request header and validation of response Content-Type header.
`private String`
`supportedContentTypesValue`
Generated Accept request header value.
`private Set<MediaType>`
`supportedMediaTypes`
Supported `MediaType` instances, constructed from the `supportedContentTypes` list.

### Fields inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver

`METRIC_GAUGE_NUM_LIVE_ENTITYIDS, METRIC_GAUGE_PERSISTENT_CACHE_INIT, METRIC_RATIOGAUGE_FETCH_TO_RESOLVE, METRIC_TIMER_FETCH_FROM_ORIGIN_SOURCE, METRIC_TIMER_RESOLVE`

## Constructor Summary

Constructors
Constructor
Description
`AbstractDynamicHTTPMetadataResolver(Timer backgroundTaskTimer, org.apache.hc.client5.http.classic.HttpClient client)`
Constructor.
`AbstractDynamicHTTPMetadataResolver(org.apache.hc.client5.http.classic.HttpClient client)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected org.apache.hc.client5.http.protocol.HttpClientContext`
`buildHttpClientContext(org.apache.hc.core5.http.ClassicHttpRequest request)`
Build the `HttpClientContext` instance which will be used to invoke the `HttpClient` request.
`protected org.apache.hc.core5.http.ClassicHttpRequest`
`buildHttpRequest(CriteriaSet criteria)`
Build an appropriate instance of `ClassicHttpRequest` based on the input criteria set.
`protected abstract String`
`buildRequestURL(CriteriaSet criteria)`
Build the request URL based on the input criteria set.
`protected void`
`doDestroy()`
`protected XMLObject`
`fetchFromOriginSource(CriteriaSet criteria)`
Fetch the metadata from the origin source.
`protected HttpClientSecurityParameters`
`getHttpClientSecurityParameters()`
Get the instance of `HttpClientSecurityParameters` which provides various parameters to influence the security behavior of the HttpClient instance.
`List<String>`
`getSupportedContentTypes()`
Get the list of supported MIME types for use in Accept request header and validation of response Content-Type header.
`protected Set<MediaType>`
`getSupportedMediaTypes()`
Get the list of supported MIME `MediaType` instances used in validation of the response Content-Type header.
`protected void`
`initMetadataResolver()`
Subclasses should override this method to perform any initialization logic necessary.
`void`
`setHttpClientSecurityParameters(HttpClientSecurityParameters params)`
Set an instance of `HttpClientSecurityParameters` which provides various parameters to influence the security behavior of the HttpClient instance.
`void`
`setSupportedContentTypes(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 org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver

`clear, clear, computeExpirationTime, computeRefreshTriggerTime, createNewBackingStore, doResolve, ensureBackingStore, ensurePersistentCacheManager, getBackgroundInitializationFromCacheDelay, getBackingStore, getCleanupTaskInterval, getExpirationWarningThreshold, getIndexes, getInitializationFromCachePredicate, getMaxCacheDuration, getMaxIdleEntityData, getMinCacheDuration, getNegativeLookupCacheDuration, getPersistentCacheKeyGenerator, getPersistentCacheManager, getRefreshDelayFactor, indexEntityDescriptor, indexesEnabled, initializeFromPersistentCache, isInitializeFromPersistentCacheInBackground, isPersistentCachingEnabled, isRemoveIdleEntityData, lookupCriteria, lookupEntityID, prepareForFiltering, preProcessEntityDescriptor, processNewMetadata, processNewMetadata, processNonEntityIDFetchedEntittiesDescriptor, processNonEntityIDFetchedEntityDescriptor, processPersistentCacheEntry, removeByEntityID, resolveEntityID, resolveEntityIDs, resolveFromOriginSource, resolveFromOriginSourceWithEntityID, resolveFromOriginSourceWithoutEntityID, setBackgroundInitializationFromCacheDelay, setCleanupTaskInterval, setExpirationWarningThreshold, setIndexes, setInitializationFromCachePredicate, setInitializeFromPersistentCacheInBackground, setMaxCacheDuration, setMaxIdleEntityData, setMinCacheDuration, setNegativeLookupCacheDuration, setPersistentCacheKeyGenerator, setPersistentCacheManager, setRefreshDelayFactor, setRemoveIdleEntityData, shouldAttemptRefresh`

### Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver

`doInitialize, filterMetadata, getActivationCondition, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getMetricsBaseName, getParserPool, getType, getUnmarshallerFactory, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupIndexedEntityID, newFilterContext, predicateFilterCandidates, preProcessEntitiesDescriptor, releaseMetadataDOM, resolve, resolveSingle, setActivationCondition, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setMetricsBaseName, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setType, setUseDefaultPredicateRegistry, unmarshallMetadata`

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

`setId`

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

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

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

`checkComponentActive, checkSetterPreconditions, destroy, 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.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface org.opensaml.saml.metadata.resolver.MetadataResolver

`getMetadataFilter, getType, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata`

### Methods inherited from interface net.shibboleth.shared.resolver.Resolver

`resolve, resolveSingle`

## Field Details

### DEFAULT_CONTENT_TYPES

@Nonnull @NotEmpty public static final String[] DEFAULT_CONTENT_TYPES
Default list of supported content MIME types.

### MDC_ATTRIB_CURRENT_REQUEST_URI

@Nonnull @NotEmpty public static final String MDC_ATTRIB_CURRENT_REQUEST_URI
MDC attribute representing the current request URI. Will be available during the execution of the configured `HttpClientResponseHandler`.

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### httpClient

@NonnullAfterInit private org.apache.hc.client5.http.classic.HttpClient httpClient
HTTP Client used to pull the metadata.

### 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
Supported `MediaType` instances, constructed from the `supportedContentTypes` list.

### responseHandler

@Nonnull private org.apache.hc.core5.http.io.HttpClientResponseHandler<XMLObject> responseHandler
HttpClient ResponseHandler instance to use.

### httpClientSecurityParameters

@Nullable private HttpClientSecurityParameters httpClientSecurityParameters
Optional HttpClient security parameters.

## Constructor Details

### AbstractDynamicHTTPMetadataResolver

public AbstractDynamicHTTPMetadataResolver(@Nonnull org.apache.hc.client5.http.classic.HttpClient client)
Constructor.

Parameters:
  `client` - the instance of `HttpClient` used to fetch remote metadata

### AbstractDynamicHTTPMetadataResolver

public AbstractDynamicHTTPMetadataResolver(@Nullable Timer backgroundTaskTimer, @Nonnull org.apache.hc.client5.http.classic.HttpClient client)
Constructor.

Parameters:
  `backgroundTaskTimer` - the `Timer` instance used to run resolver background managment tasks
  `client` - the instance of `HttpClient` used to fetch remote metadata

## Method Details

### getHttpClientSecurityParameters

@Nullable protected HttpClientSecurityParameters getHttpClientSecurityParameters()
Get the instance of `HttpClientSecurityParameters` which provides various parameters to influence the security behavior of the HttpClient instance.

Returns:
  the parameters instance, or null

### setHttpClientSecurityParameters

public void setHttpClientSecurityParameters(@Nullable HttpClientSecurityParameters params)
Set an instance of `HttpClientSecurityParameters` which 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 `SecurityEnhancedTLSSocketFactory` which wraps an instance of `TLSSocketFactory`, 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`, see `HttpClientSupport`.

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 `ResolverException` will ultimately be thrown.

Parameters:
  `params` - the security parameters

### getSupportedMediaTypes

@NonnullAfterInit @NotLive @Unmodifiable protected Set<MediaType> getSupportedMediaTypes()
Get the list of supported MIME `MediaType` instances used in validation of the response Content-Type header.

Is generated at init time from `getSupportedContentTypes()`.

Returns:
  the supported content types

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

### initMetadataResolver

protected void initMetadataResolver() throws ComponentInitializationException
Subclasses should override this method to perform any initialization logic necessary. Default implementation is a no-op.

Overrides:
  `initMetadataResolver` in class `AbstractDynamicMetadataResolver`
Throws:
  `ComponentInitializationException` - thrown if there is a problem initializing the provider

### doDestroy

protected void doDestroy()

Overrides:
  `doDestroy` in class `AbstractDynamicMetadataResolver`

### fetchFromOriginSource

@Nullable protected XMLObject fetchFromOriginSource(@Nullable CriteriaSet criteria) throws IOException
Fetch the metadata from the origin source.

Specified by:
  `fetchFromOriginSource` in class `AbstractDynamicMetadataResolver`
Parameters:
  `criteria` - the input criteria set
Returns:
  the resolved metadata root XMLObject, or null if metadata could not be fetched
Throws:
  `IOException` - if there is a fatal error fetching metadata from the origin source

### buildHttpRequest

@Nullable protected org.apache.hc.core5.http.ClassicHttpRequest buildHttpRequest(@Nullable CriteriaSet criteria)
Build an appropriate instance of `ClassicHttpRequest` based 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(@Nullable 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

### buildHttpClientContext

@Nonnull protected org.apache.hc.client5.http.protocol.HttpClientContext buildHttpClientContext(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request)
Build the `HttpClientContext` instance which will be used to invoke the `HttpClient` request.

Parameters:
  `request` - the current HTTP request
Returns:
  a new instance of `HttpClientContext`