Class HTTPMetadataResolver
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.AbstractBatchMetadataResolver
org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver
org.opensaml.saml.metadata.resolver.impl.HTTPMetadataResolver
- All Implemented Interfaces:
Iterable<EntityDescriptor>,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,Resolver<EntityDescriptor,,CriteriaSet> IterableMetadataSource,BatchMetadataResolver,MetadataResolver,RefreshableMetadataResolver,RemoteMetadataResolver
- Direct Known Subclasses:
FileBackedHTTPMetadataResolver
public class HTTPMetadataResolver
extends AbstractReloadingMetadataResolver
implements RemoteMetadataResolver
A metadata provider that pulls metadata using an HTTP GET. Metadata is cached until one of these criteria is met:
- The smallest cacheDuration within the metadata is exceeded
- The earliest validUntil time within the metadata is exceeded
- The maximum cache duration is exceeded
AbstractInitializableComponent.initialize(), if any properties of this
provider are changed.-
Nested Class Summary
Nested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver
AbstractBatchMetadataResolver.BatchEntityBackingStoreNested classes/interfaces inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver
AbstractMetadataResolver.EntityBackingStore -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe ETag provided when the currently cached metadata was fetched.private StringThe Last-Modified information provided when the currently cached metadata was fetched.private org.apache.hc.client5.http.classic.HttpClientHTTP Client used to pull the metadata.private HttpClientSecurityParametersOptional HttpClient security parameters.private final org.slf4j.LoggerClass logger.private URIURL to the Metadata.Fields inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver
METRIC_TIMER_REFRESH -
Constructor Summary
ConstructorsConstructorDescriptionHTTPMetadataResolver(Timer backgroundTaskTimer, org.apache.hc.client5.http.classic.HttpClient client, String metadataURL) Constructor.HTTPMetadataResolver(org.apache.hc.client5.http.classic.HttpClient client, String metadataURL) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.hc.client5.http.protocol.HttpClientContextbuildHttpClientContext(org.apache.hc.core5.http.ClassicHttpRequest request) Build theHttpClientContextinstance which will be used to invoke theHttpClientrequest.protected org.apache.hc.client5.http.classic.methods.HttpGetBuilds theHttpGetinstance used to fetch the metadata.protected voidprotected byte[]Gets the metadata document from the remote server.protected HttpClientSecurityParametersGet the instance ofHttpClientSecurityParameterswhich provides various parameters to influence the security behavior of the HttpClient instance.protected byte[]getMetadataBytesFromResponse(org.apache.hc.core5.http.ClassicHttpResponse response) Extracts the raw metadata bytes from the response taking in to account possible deflate and GZip compression.protected StringGets an identifier which may be used to distinguish this metadata in logging statements.Gets the URI from which this resolver is obtaining metadata.protected voidprocessConditionalRetrievalHeaders(org.apache.hc.core5.http.ClassicHttpResponse response) Records the ETag and Last-Modified headers, from the response, if they are present.voidSet an instance ofHttpClientSecurityParameterswhich provides various parameters to influence the security behavior of the HttpClient instance.Methods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractReloadingMetadataResolver
computeNextRefreshDelay, getExpirationTime, getExpirationWarningThreshold, getLastFailureCause, getLastRefresh, getLastSuccessfulRefresh, getLastUpdate, getMaxRefreshDelay, getMinRefreshDelay, getNextRefresh, getRefreshDelayFactor, initMetadataResolver, inputstreamToByteArray, postProcessMetadata, processCachedMetadata, processNewMetadata, processNonExpiredMetadata, processPreExpiredMetadata, refresh, setCacheSourceMetadata, setExpirationWarningThreshold, setMaxRefreshDelay, setMinRefreshDelay, setRefreshDelayFactor, unmarshallMetadata, wasLastRefreshSuccessMethods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractBatchMetadataResolver
createNewBackingStore, doResolve, ensureBackingStore, getCachedFilteredMetadata, getCachedOriginalMetadata, getIndexes, getRootValidUntil, indexEntityDescriptor, isCacheSourceMetadata, isResolveViaPredicatesOnly, isRootValid, iterator, lookupByIndexes, preProcessNewMetadata, setIndexes, setResolveViaPredicatesOnlyMethods inherited from class org.opensaml.saml.metadata.resolver.impl.AbstractMetadataResolver
doInitialize, filterMetadata, getActivationCondition, getBackingStore, getCriterionPredicateRegistry, getLogPrefix, getMetadataFilter, getMetricsBaseName, getParserPool, getType, getUnmarshallerFactory, isFailFastInitialization, isRequireValidMetadata, isSatisfyAnyPredicates, isUseDefaultPredicateRegistry, isValid, lookupEntityID, lookupIndexedEntityID, newFilterContext, predicateFilterCandidates, preProcessEntitiesDescriptor, preProcessEntityDescriptor, releaseMetadataDOM, removeByEntityID, resolve, resolveSingle, setActivationCondition, setBackingStore, setCriterionPredicateRegistry, setFailFastInitialization, setMetadataFilter, setMetricsBaseName, setParserPool, setRequireValidMetadata, setSatisfyAnyPredicates, setType, setUseDefaultPredicateRegistry, unmarshallMetadataMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.IdentifiedComponent
getIdMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.opensaml.saml.metadata.resolver.MetadataResolver
getMetadataFilter, getType, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadataMethods inherited from interface net.shibboleth.shared.resolver.Resolver
resolve, resolveSingle
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
httpClient
HTTP Client used to pull the metadata. -
metadataURI
URL to the Metadata. -
cachedMetadataETag
The ETag provided when the currently cached metadata was fetched. -
cachedMetadataLastModified
The Last-Modified information provided when the currently cached metadata was fetched. -
httpClientSecurityParameters
Optional HttpClient security parameters.
-
-
Constructor Details
-
HTTPMetadataResolver
public HTTPMetadataResolver(@Nonnull org.apache.hc.client5.http.classic.HttpClient client, String metadataURL) throws ResolverException Constructor.- Parameters:
client- HTTP client used to pull in remote metadatametadataURL- URL to the remove remote metadata- Throws:
ResolverException- thrown if the HTTP client is null or the metadata URL provided is invalid
-
HTTPMetadataResolver
public HTTPMetadataResolver(Timer backgroundTaskTimer, @Nonnull org.apache.hc.client5.http.classic.HttpClient client, String metadataURL) throws ResolverException Constructor.- Parameters:
backgroundTaskTimer- timer used to schedule background metadata refresh tasksclient- HTTP client used to pull in remote metadatametadataURL- URL to the remove remote metadata- Throws:
ResolverException- thrown if the HTTP client is null or the metadata URL provided is invalid
-
-
Method Details
-
getMetadataURI
Gets the URI from which this resolver is obtaining metadata.- Specified by:
getMetadataURIin interfaceRemoteMetadataResolver- Returns:
- URL source of metadata
-
getHttpClientSecurityParameters
Get the instance ofHttpClientSecurityParameterswhich provides various parameters to influence the security behavior of the HttpClient instance.- Returns:
- the parameters instance, or null
-
setHttpClientSecurityParameters
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:
-
a
TLSSocketFactory -
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
-
doDestroy
protected void doDestroy()- Overrides:
doDestroyin classAbstractReloadingMetadataResolver
-
getMetadataIdentifier
Gets an identifier which may be used to distinguish this metadata in logging statements.- Specified by:
getMetadataIdentifierin classAbstractReloadingMetadataResolver- Returns:
- identifier which may be used to distinguish this metadata in logging statements
-
fetchMetadata
Gets the metadata document from the remote server.- Specified by:
fetchMetadatain classAbstractReloadingMetadataResolver- Returns:
- the metadata from remote server, or null if the metadata document has not changed since the last retrieval
- Throws:
ResolverException- thrown if there is a problem retrieving the metadata from the remote server
-
buildHttpGet
@Nonnull protected org.apache.hc.client5.http.classic.methods.HttpGet buildHttpGet()Builds theHttpGetinstance used to fetch the metadata. The returned method advertises support for GZIP and deflate compression, enables conditional GETs if the cached metadata came with either an ETag or Last-Modified information, and sets up basic authentication if such is configured.- Returns:
- the constructed HttpGet instance
-
buildHttpClientContext
@Nonnull protected org.apache.hc.client5.http.protocol.HttpClientContext buildHttpClientContext(@Nonnull org.apache.hc.core5.http.ClassicHttpRequest request) Build theHttpClientContextinstance which will be used to invoke theHttpClientrequest.- Parameters:
request- the current HTTP request- Returns:
- a new instance of
HttpClientContext
-
processConditionalRetrievalHeaders
protected void processConditionalRetrievalHeaders(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse response) Records the ETag and Last-Modified headers, from the response, if they are present.- Parameters:
response- GetMethod containing a valid HTTP response
-
getMetadataBytesFromResponse
@Nonnull protected byte[] getMetadataBytesFromResponse(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse response) throws ResolverException Extracts the raw metadata bytes from the response taking in to account possible deflate and GZip compression.- Parameters:
response- GetMethod containing a valid HTTP response- Returns:
- the raw metadata bytes
- Throws:
ResolverException- thrown if there is a problem getting the raw metadata bytes from the response
-