Class ChainingMetadataResolver
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.ChainingMetadataResolver
- All Implemented Interfaces:
Component
,DestructableComponent
,IdentifiableComponent
,IdentifiedComponent
,InitializableComponent
,Resolver<EntityDescriptor,
,CriteriaSet> ClearableMetadataResolver
,MetadataResolver
,RefreshableMetadataResolver
public class ChainingMetadataResolver
extends AbstractIdentifiableInitializableComponent
implements MetadataResolver, RefreshableMetadataResolver, ClearableMetadataResolver
A metadata provider that uses registered resolvers, in turn, to answer queries.
The Iterable of entity descriptors returned is the first non-null and non-empty Iterable found while iterating over
the registered resolvers in resolver list order.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DetectDuplicateEntityIDs
Strategy for detecting duplicate entityIDs across resolvers.private final org.slf4j.Logger
Class logger.private List<MetadataResolver>
Registered resolvers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Attempt to clear all data from the internal cache of the resolver.void
Attempt to clear data from the internal cache of the resolver for the specified entityID.collectEntityIDs
(Iterable<EntityDescriptor> descriptors) Collect the unique entityIDs from the supplied iterable of entity descriptors.private void
detectDuplicateEntityIDs
(MetadataResolver resolver, CriteriaSet criteria, Set<String> resultEntityIDs, DetectDuplicateEntityIDs detectDuplicates) Perform duplicate entityID detection.protected void
protected void
Get the strategy for detecting duplicate entityIDs across resolvers.Gets the reason the last refresh failed.Gets the time the last refresh cycle occurred.Gets the time the last successful refresh cycle occurred.Get the time that the currently available metadata was last updated.Gets the metadata filter applied to the metadata.Get an immutable the list of currently registered resolvers.boolean
Gets whether the metadata returned by queries must be valid.void
refresh()
Refresh the data exposed by the resolver.resolve
(CriteriaSet criteria) resolveSingle
(CriteriaSet criteria) void
Set the strategy for detecting duplicate entityIDs across resolvers.void
setMetadataFilter
(MetadataFilter newFilter) Sets the metadata filter applied to the metadata.void
setRequireValidMetadata
(boolean requireValidMetadata) Sets whether the metadata returned by queries must be valid.void
setResolvers
(List<? extends MetadataResolver> newResolvers) Set the registered metadata resolvers.Gets whether the last refresh cycle was successful.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
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
resolvers
Registered resolvers. -
detectDuplicateEntityIDs
Strategy for detecting duplicate entityIDs across resolvers.
-
-
Constructor Details
-
ChainingMetadataResolver
public ChainingMetadataResolver()Constructor.
-
-
Method Details
-
getResolvers
Get an immutable the list of currently registered resolvers.- Returns:
- list of currently registered resolvers
-
setResolvers
public void setResolvers(@Nonnull @NonnullElements List<? extends MetadataResolver> newResolvers) throws ResolverException Set the registered metadata resolvers.- Parameters:
newResolvers
- the metadata resolvers to use- Throws:
ResolverException
- thrown if there is a problem adding the metadata resolvers
-
getDetectDuplicateEntityIDs
Get the strategy for detecting duplicate entityIDs across resolvers.- Returns:
- the configured strategy
-
setDetectDuplicateEntityIDs
Set the strategy for detecting duplicate entityIDs across resolvers.- Parameters:
strategy
- the strategy to configure
-
isRequireValidMetadata
public boolean isRequireValidMetadata()Gets whether the metadata returned by queries must be valid.At a minimum, metadata is valid only if the date expressed in the
validUntil
attribute of the element and all its ancestral elements has not passed. Specific implementations may add additional constraints.- Specified by:
isRequireValidMetadata
in interfaceMetadataResolver
- Returns:
- whether the metadata returned by queries must be valid
-
setRequireValidMetadata
public void setRequireValidMetadata(boolean requireValidMetadata) Sets whether the metadata returned by queries must be valid.- Specified by:
setRequireValidMetadata
in interfaceMetadataResolver
- Parameters:
requireValidMetadata
- whether the metadata returned by queries must be valid
-
getMetadataFilter
Gets the metadata filter applied to the metadata.- Specified by:
getMetadataFilter
in interfaceMetadataResolver
- Returns:
- the metadata filter applied to the metadata
-
setMetadataFilter
Sets the metadata filter applied to the metadata.- Specified by:
setMetadataFilter
in interfaceMetadataResolver
- Parameters:
newFilter
- the metadata filter applied to the metadata
-
resolveSingle
@Nullable public EntityDescriptor resolveSingle(@Nullable CriteriaSet criteria) throws ResolverException - Specified by:
resolveSingle
in interfaceResolver<EntityDescriptor,
CriteriaSet> - Throws:
ResolverException
-
resolve
@Nonnull public Iterable<EntityDescriptor> resolve(@Nullable CriteriaSet criteria) throws ResolverException - Specified by:
resolve
in interfaceResolver<EntityDescriptor,
CriteriaSet> - Throws:
ResolverException
-
detectDuplicateEntityIDs
private void detectDuplicateEntityIDs(@Nonnull MetadataResolver resolver, @Nonnull CriteriaSet criteria, @Nullable Set<String> resultEntityIDs, @Nonnull DetectDuplicateEntityIDs detectDuplicates) Perform duplicate entityID detection.- Parameters:
resolver
- the metadata resolver over which to perform duplicate detectioncriteria
- the current criteria setresultEntityIDs
- the set of entityIDs contained in the effective results to be returneddetectDuplicates
- the effective strategy for duplicate detection
-
collectEntityIDs
Collect the unique entityIDs from the supplied iterable of entity descriptors.- Parameters:
descriptors
-- Returns:
- the unique entityIDs from the supplied descriptors
-
clear
Attempt to clear all data from the internal cache of the resolver.- Specified by:
clear
in interfaceClearableMetadataResolver
- Throws:
ResolverException
- if the clear operation was unsuccessful
-
clear
Attempt to clear data from the internal cache of the resolver for the specified entityID.- Specified by:
clear
in interfaceClearableMetadataResolver
- Parameters:
entityID
- the target entityID- Throws:
ResolverException
- if the clear operation was unsuccessful
-
refresh
Refresh the data exposed by the resolver.An implementation of this method should typically be either
synchronized
or make use other locking mechanisms to protect against concurrent access.- Specified by:
refresh
in interfaceRefreshableMetadataResolver
- Throws:
ResolverException
- if the refresh operation was unsuccessful
-
getLastUpdate
Get the time that the currently available metadata was last updated. Note, this may be different than the time retrieved byRefreshableMetadataResolver.getLastRefresh()
is the metadata was known not to have changed during the last refresh cycle. We iterate over all the children and return the earliest instant or null if one of them hasn't ever updated.- Specified by:
getLastUpdate
in interfaceRefreshableMetadataResolver
- Returns:
- time when the currently metadata was last updated, null if metadata has never successfully been read in
-
getLastRefresh
Gets the time the last refresh cycle occurred. We iterate over all the children and return the earliest instant or null if one of them hasn't ever refreshed.- Specified by:
getLastRefresh
in interfaceRefreshableMetadataResolver
- Returns:
- time the last refresh cycle occurred
-
getLastSuccessfulRefresh
Gets the time the last successful refresh cycle occurred. We iterate over all the children and return the earliest instant or null if one of them hasn't ever refreshed successfully.- Specified by:
getLastSuccessfulRefresh
in interfaceRefreshableMetadataResolver
- Returns:
- time the last successful refresh cycle occurred
-
wasLastRefreshSuccess
Gets whether the last refresh cycle was successful. We iterate over all children - a failure of any is a failure.- Specified by:
wasLastRefreshSuccess
in interfaceRefreshableMetadataResolver
- Returns:
- true if last refresh cycle was successful, false if not
-
getLastFailureCause
Gets the reason the last refresh failed. We iterate over all children and return the first failure we find.- Specified by:
getLastFailureCause
in interfaceRefreshableMetadataResolver
- Returns:
- reason the last refresh failed or null if the last refresh was successful
-
doInitialize
- Overrides:
doInitialize
in classAbstractIdentifiedInitializableComponent
- Throws:
ComponentInitializationException
-
doDestroy
protected void doDestroy()- Overrides:
doDestroy
in classAbstractInitializableComponent
-