public class HTTPMetadataResolver extends AbstractReloadingMetadataResolver
AbstractInitializableComponent.initialize(), if any properties of this
provider are changed.AbstractBatchMetadataResolver.BatchEntityBackingStoreAbstractMetadataResolver.EntityBackingStore| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
cachedMetadataETag
The ETag provided when the currently cached metadata was fetched.
|
private java.lang.String |
cachedMetadataLastModified
The Last-Modified information provided when the currently cached metadata was fetched.
|
private org.apache.http.impl.client.BasicCredentialsProvider |
credentialsProvider
HttpClient credentials provider.
|
private org.apache.http.client.HttpClient |
httpClient
HTTP Client used to pull the metadata.
|
private org.slf4j.Logger |
log
Class logger.
|
private java.net.URI |
metadataURI
URL to the Metadata.
|
private TrustEngine<? super X509Credential> |
tlsTrustEngine
Optional trust engine used in evaluating server TLS credentials.
|
| Constructor and Description |
|---|
HTTPMetadataResolver(org.apache.http.client.HttpClient client,
java.lang.String metadataURL)
Constructor.
|
HTTPMetadataResolver(java.util.Timer backgroundTaskTimer,
org.apache.http.client.HttpClient client,
java.lang.String metadataURL)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.apache.http.client.protocol.HttpClientContext |
buildHttpClientContext()
Build the
HttpClientContext instance which will be used to invoke the HttpClient request. |
protected org.apache.http.client.methods.HttpGet |
buildHttpGet()
Builds the
HttpGet instance used to fetch the metadata. |
protected void |
checkTLSCredentialTrusted(org.apache.http.client.protocol.HttpClientContext context)
Check that trust engine evaluation of the server TLS credential was actually performed.
|
protected void |
doDestroy() |
protected byte[] |
fetchMetadata()
Gets the metadata document from the remote server.
|
protected byte[] |
getMetadataBytesFromResponse(org.apache.http.HttpResponse response)
Extracts the raw metadata bytes from the response taking in to account possible deflate and GZip compression.
|
protected java.lang.String |
getMetadataIdentifier()
Gets an identifier which may be used to distinguish this metadata in logging statements.
|
java.lang.String |
getMetadataURI()
Gets the URL to fetch the metadata.
|
protected void |
processConditionalRetrievalHeaders(org.apache.http.HttpResponse response)
Records the ETag and Last-Modified headers, from the response, if they are present.
|
void |
setBasicCredentials(org.apache.http.auth.UsernamePasswordCredentials credentials)
Sets the username and password used to access the metadata URL.
|
void |
setBasicCredentialsWithScope(org.apache.http.auth.UsernamePasswordCredentials credentials,
org.apache.http.auth.AuthScope scope)
Sets the username and password used to access the metadata URL.
|
void |
setTLSTrustEngine(TrustEngine<? super X509Credential> engine)
Sets the optional trust engine used in evaluating server TLS credentials.
|
computeNextRefreshDelay, getExpirationTime, getLastRefresh, getLastUpdate, getMaxRefreshDelay, getMinRefreshDelay, getNextRefresh, getRefreshDelayFactor, initMetadataResolver, inputstreamToByteArray, postProcessMetadata, processCachedMetadata, processNewMetadata, processNonExpiredMetadata, processPreExpiredMetadata, refresh, setCacheSourceMetadata, setMaxRefreshDelay, setMinRefreshDelay, setRefreshDelayFactor, unmarshallMetadatacreateNewBackingStore, getBackingStore, getCachedFilteredMetadata, getCachedOriginalMetadata, isCacheSourceMetadata, iterator, preProcessNewMetadata, resolvedoInitialize, filterMetadata, getMetadataFilter, getParserPool, getUnmarshallerFactory, indexEntityDescriptor, isFailFastInitialization, isRequireValidMetadata, isValid, lookupEntityID, lookupIndexedEntityID, preProcessEntitiesDescriptor, preProcessEntityDescriptor, releaseMetadataDOM, removeByEntityID, resolveSingle, setBackingStore, setFailFastInitialization, setMetadataFilter, setParserPool, setRequireValidMetadata, unmarshallMetadatasetIdgetIddestroy, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMetadataFilter, isRequireValidMetadata, setMetadataFilter, setRequireValidMetadataresolve, resolveSingleprivate final org.slf4j.Logger log
private org.apache.http.client.HttpClient httpClient
private java.net.URI metadataURI
private java.lang.String cachedMetadataETag
private java.lang.String cachedMetadataLastModified
private org.apache.http.impl.client.BasicCredentialsProvider credentialsProvider
private TrustEngine<? super X509Credential> tlsTrustEngine
public HTTPMetadataResolver(org.apache.http.client.HttpClient client,
java.lang.String metadataURL)
throws net.shibboleth.utilities.java.support.resolver.ResolverException
client - HTTP client used to pull in remote metadatametadataURL - URL to the remove remote metadatanet.shibboleth.utilities.java.support.resolver.ResolverException - thrown if the HTTP client is null or the metadata URL provided is invalidpublic HTTPMetadataResolver(java.util.Timer backgroundTaskTimer,
org.apache.http.client.HttpClient client,
java.lang.String metadataURL)
throws net.shibboleth.utilities.java.support.resolver.ResolverException
backgroundTaskTimer - timer used to schedule background metadata refresh tasksclient - HTTP client used to pull in remote metadatametadataURL - URL to the remove remote metadatanet.shibboleth.utilities.java.support.resolver.ResolverException - thrown if the HTTP client is null or the metadata URL provided is invalidpublic java.lang.String getMetadataURI()
public void setTLSTrustEngine(@Nullable
TrustEngine<? super X509Credential> engine)
Must be used in conjunction with an HttpClient instance which is configured with a
TrustEngineTLSSocketFactory. If this socket
factory is not configured, then this will result in no TLS trust evaluation being performed
and a ResolverException will ultimately be thrown.
engine - the trust engine instance to usepublic void setBasicCredentials(@Nullable
org.apache.http.auth.UsernamePasswordCredentials credentials)
AuthScope will be generated based off the metadata URI's hostname and port.credentials - the username and password credentialspublic void setBasicCredentialsWithScope(@Nullable
org.apache.http.auth.UsernamePasswordCredentials credentials,
@Nullable
org.apache.http.auth.AuthScope scope)
If the authScope is null, an AuthScope will be generated based off the metadata URI's
hostname and port.
credentials - the username and password credentialsscope - the HTTP client auth scope with which to scope the credentials, may be nullprotected void doDestroy()
doDestroy in class AbstractReloadingMetadataResolverprotected java.lang.String getMetadataIdentifier()
getMetadataIdentifier in class AbstractReloadingMetadataResolverprotected byte[] fetchMetadata()
throws net.shibboleth.utilities.java.support.resolver.ResolverException
fetchMetadata in class AbstractReloadingMetadataResolvernet.shibboleth.utilities.java.support.resolver.ResolverException - thrown if there is a problem retrieving the metadata from the remote serverprotected void checkTLSCredentialTrusted(org.apache.http.client.protocol.HttpClientContext context)
throws javax.net.ssl.SSLPeerUnverifiedException
context - the current HTTP context instance in usejavax.net.ssl.SSLPeerUnverifiedException - thrown if the TLS credential was not actually evaluated by the trust engineprotected org.apache.http.client.methods.HttpGet buildHttpGet()
HttpGet instance 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.protected org.apache.http.client.protocol.HttpClientContext buildHttpClientContext()
HttpClientContext instance which will be used to invoke the HttpClient request.HttpClientContextprotected void processConditionalRetrievalHeaders(org.apache.http.HttpResponse response)
response - GetMethod containing a valid HTTP responseprotected byte[] getMetadataBytesFromResponse(org.apache.http.HttpResponse response)
throws net.shibboleth.utilities.java.support.resolver.ResolverException
response - GetMethod containing a valid HTTP responsenet.shibboleth.utilities.java.support.resolver.ResolverException - thrown if there is a problem getting the raw metadata bytes from the response