Class AbstractDynamicHTTPMetadataResolver
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.utilities.java.support.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 classAbstractDynamicHTTPMetadataResolver.BasicMetadataResponseHandlerBasic 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 String[]DEFAULT_CONTENT_TYPESDefault list of supported content MIME types.private org.apache.http.client.HttpClienthttpClientHTTP Client used to pull the metadata.private HttpClientSecurityParametershttpClientSecurityParametersOptional HttpClient 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<XMLObject>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.-
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.http.client.HttpClient client)Constructor.AbstractDynamicHTTPMetadataResolver(org.apache.http.client.HttpClient client)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.apache.http.client.protocol.HttpClientContextbuildHttpClientContext(org.apache.http.client.methods.HttpUriRequest request)Build theHttpClientContextinstance which will be used to invoke theHttpClientrequest.protected 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 voiddoDestroy()protected XMLObjectfetchFromOriginSource(CriteriaSet criteria)Fetch the metadata from the origin source.protected HttpClientSecurityParametersgetHttpClientSecurityParameters()Get the instance ofHttpClientSecurityParameterswhich 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 MIMEMediaTypeinstances used in validation of the response Content-Type header.protected voidinitMetadataResolver()Subclasses should override this method to perform any initialization logic necessary.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 org.opensaml.saml.metadata.resolver.impl.AbstractDynamicMetadataResolver
clear, clear, computeExpirationTime, computeRefreshTriggerTime, createNewBackingStore, getBackgroundInitializationFromCacheDelay, getBackingStore, getCleanupTaskInterval, getExpirationWarningThreshold, getIndexes, getInitializationFromCachePredicate, getMaxCacheDuration, getMaxIdleEntityData, getMetricsBaseName, getMinCacheDuration, getNegativeLookupCacheDuration, getPersistentCacheKeyGenerator, getPersistentCacheManager, getRefreshDelayFactor, indexEntityDescriptor, indexesEnabled, initializeFromPersistentCache, isInitializeFromPersistentCacheInBackground, isPersistentCachingEnabled, isRemoveIdleEntityData, lookupCriteria, lookupEntityID, prepareForFiltering, preProcessEntityDescriptor, processNewMetadata, processNewMetadata, processNonEntityIDFetchedEntittiesDescriptor, processNonEntityIDFetchedEntityDescriptor, processPersistentCacheEntry, removeByEntityID, resolve, resolveEntityID, resolveEntityIDs, resolveFromOriginSource, resolveFromOriginSourceWithEntityID, resolveFromOriginSourceWithoutEntityID, setBackgroundInitializationFromCacheDelay, setCleanupTaskInterval, setExpirationWarningThreshold, setIndexes, setInitializationFromCachePredicate, setInitializeFromPersistentCacheInBackground, setMaxCacheDuration, setMaxIdleEntityData, setMetricsBaseName, setMinCacheDuration, setNegativeLookupCacheDuration, setPersistentCacheKeyGenerator, setPersistentCacheManager, setRefreshDelayFactor, setRemoveIdleEntityData, shouldAttemptRefresh
-
Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver
doInitialize, filterMetadata, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getParserPool, getUnmarshallerFactory, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupIndexedEntityID, newFilterContext, predicateFilterCandidates, preProcessEntitiesDescriptor, releaseMetadataDOM, resolveSingle, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setUseDefaultPredicateRegistry, unmarshallMetadata
-
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, 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
-
Methods inherited from interface org.opensaml.saml.metadata.resolver.MetadataResolver
getMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadata
-
Methods inherited from interface net.shibboleth.utilities.java.support.resolver.Resolver
resolveSingle
-
-
-
-
Field Detail
-
DEFAULT_CONTENT_TYPES
public static final String[] DEFAULT_CONTENT_TYPES
Default list of supported content MIME types.
-
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.
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
httpClient
@Nonnull private org.apache.http.client.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
SupportedMediaTypeinstances, constructed from thesupportedContentTypeslist.
-
responseHandler
@Nonnull private org.apache.http.client.ResponseHandler<XMLObject> responseHandler
HttpClient ResponseHandler instance to use.
-
httpClientSecurityParameters
@Nullable private HttpClientSecurityParameters httpClientSecurityParameters
Optional HttpClient security parameters.
-
-
Constructor Detail
-
AbstractDynamicHTTPMetadataResolver
public AbstractDynamicHTTPMetadataResolver(@Nonnull org.apache.http.client.HttpClient client)Constructor.- Parameters:
client- the instance ofHttpClientused to fetch remote metadata
-
AbstractDynamicHTTPMetadataResolver
public AbstractDynamicHTTPMetadataResolver(@Nullable Timer backgroundTaskTimer, @Nonnull org.apache.http.client.HttpClient client)Constructor.- Parameters:
backgroundTaskTimer- theTimerinstance used to run resolver background managment tasksclient- the instance ofHttpClientused to fetch remote metadata
-
-
Method Detail
-
getHttpClientSecurityParameters
@Nullable protected HttpClientSecurityParameters getHttpClientSecurityParameters()
Get the instance ofHttpClientSecurityParameterswhich 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 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
-
getSupportedMediaTypes
@NonnullAfterInit @NotLive @Unmodifiable protected Set<MediaType> getSupportedMediaTypes()
Get the list of supported MIMEMediaTypeinstances 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 ComponentInitializationExceptionSubclasses should override this method to perform any initialization logic necessary. Default implementation is a no-op.- Overrides:
initMetadataResolverin classAbstractDynamicMetadataResolver- Throws:
ComponentInitializationException- thrown if there is a problem initializing the provider
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classAbstractDynamicMetadataResolver
-
fetchFromOriginSource
@Nullable protected XMLObject fetchFromOriginSource(@Nonnull CriteriaSet criteria) throws IOException
Fetch the metadata from the origin source.- Specified by:
fetchFromOriginSourcein classAbstractDynamicMetadataResolver- 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.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
-
buildHttpClientContext
protected 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
-
-