Class AbstractMetadataResolver
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
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent,Resolver<EntityDescriptor,,CriteriaSet> MetadataResolver
- Direct Known Subclasses:
AbstractBatchMetadataResolver,AbstractDynamicMetadataResolver
public abstract class AbstractMetadataResolver
extends AbstractIdentifiableInitializableComponent
implements MetadataResolver
An abstract, base, implementation of a metadata provider.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe collection of data which provides the backing store for the processed metadata. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Predicate<ProfileRequestContext>Activation condition.Registry used in resolving predicates from criteria.Backing store for runtime EntityDescriptor data.private booleanWhether problems during initialization should cause the provider to fail or go on without metadata.private final org.slf4j.LoggerClass logger.private StringLogging prefix.private MetadataFilterFilter applied to all metadata.private StringBase name for Metrics instrumentation names.private ParserPoolPool of parsers used to process XML.private booleanWhether metadata is required to be valid.private StringResolver type.private booleanFlag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false).private UnmarshallerFactoryUnmarshaller factory used to get an unmarshaller for the metadata DOM.private booleanFlag which determines whether the default predicate registry will be used if one is not supplied explicitly. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new backing store instance for EntityDescriptor data.protected voidprotected final voidprotected abstract Iterable<EntityDescriptor>doResolve(CriteriaSet criteria) Subclasses should override this method.Get the EntityDescriptor backing store currently in use by the metadata resolver, raising aConstraintViolationExceptionif null.protected XMLObjectfilterMetadata(XMLObject metadata) Filters the given metadata.Get an activation condition for this resolver.Get the EntityDescriptor backing store currently in use by the metadata resolver.Get the registry used in resolving predicates from criteria.protected StringReturn a prefix for logging messages for this component.Gets the metadata filter applied to the metadata.Get the base name for Metrics instrumentation.Gets the pool of parsers to use to parse XML.getType()Gets the type of resolver for reporting or logging purposes.protected UnmarshallerFactoryGet the XMLObject unmarshaller factory to use.protected voidindexEntityDescriptor(EntityDescriptor entityDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore) Index the specified entity descriptor, updating the specified entity backing store instance as necessary.protected voidSubclasses should override this method to perform any initialization logic necessary.booleanGets whether problems during initialization should cause the provider to fail or go on without metadata.booleanGets whether the metadata returned by queries must be valid.booleanGet the flag indicating whether resolved credentials may satisfy any predicates (i.e.booleanGet the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.protected booleanReturns whether the given descriptor is valid.protected List<EntityDescriptor>lookupEntityID(String entityID) Get list of descriptors matching an entityID.protected List<EntityDescriptor>lookupIndexedEntityID(String entityID) Lookup the specified entityID from the index.protected MetadataFilterContextGet a new instance ofMetadataFilterContextto be used when filtering metadata.protected Iterable<EntityDescriptor>predicateFilterCandidates(Iterable<EntityDescriptor> candidates, CriteriaSet criteria, boolean onEmptyPredicatesReturnEmpty) Filter the supplied candidates by resolving predicates from the supplied criteria and applying the predicates to return a filteredIterable.protected voidpreProcessEntitiesDescriptor(EntitiesDescriptor entitiesDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore) Pre-process the specified entities descriptor, updating the specified entity backing store instance as necessary.protected voidpreProcessEntityDescriptor(EntityDescriptor entityDescriptor, AbstractMetadataResolver.EntityBackingStore backingStore) Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.protected voidreleaseMetadataDOM(XMLObject metadata) Releases the DOM representation from the metadata object.protected voidremoveByEntityID(String entityID, AbstractMetadataResolver.EntityBackingStore backingStore) Remove from the backing store all metadata for the entity with the given entity ID.resolve(CriteriaSet criteria) resolveSingle(CriteriaSet criteria) voidsetActivationCondition(Predicate<ProfileRequestContext> condition) Set an activation condition for this resolver.protected voidsetBackingStore(AbstractMetadataResolver.EntityBackingStore newBackingStore) Set the EntityDescriptor backing store currently in use by the metadata resolver.voidSet the registry used in resolving predicates from criteria.voidsetFailFastInitialization(boolean failFast) Sets whether problems during initialization should cause the provider to fail or go on without metadata.voidsetMetadataFilter(MetadataFilter newFilter) Sets the metadata filter applied to the metadata.voidsetMetricsBaseName(String baseName) Set the base name for Metrics instrumentation.voidsetParserPool(ParserPool pool) Sets the pool of parsers to use to parse XML.voidsetRequireValidMetadata(boolean require) Sets whether the metadata returned by queries must be valid.voidsetSatisfyAnyPredicates(boolean flag) Set the flag indicating whether resolved credentials may satisfy any predicates (i.e.voidSets the type of this resolver for reporting/logging.voidsetUseDefaultPredicateRegistry(boolean flag) Set the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.protected XMLObjectunmarshallMetadata(InputStream metadataInput) Unmarshalls the metadata from the given stream.Methods 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
getId
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
resolverType
Resolver type. -
metricsBaseName
Base name for Metrics instrumentation names. -
unmarshallerFactory
Unmarshaller factory used to get an unmarshaller for the metadata DOM. -
requireValidMetadata
private boolean requireValidMetadataWhether metadata is required to be valid. -
mdFilter
Filter applied to all metadata. -
logPrefix
Logging prefix. -
failFastInitialization
private boolean failFastInitializationWhether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future. Default: true. -
entityBackingStore
Backing store for runtime EntityDescriptor data. -
parser
Pool of parsers used to process XML. -
satisfyAnyPredicates
private boolean satisfyAnyPredicatesFlag which determines whether predicates used in filtering are connected by a logical 'OR' (true) or by logical 'AND' (false). Defaults to false. -
criterionPredicateRegistry
Registry used in resolving predicates from criteria. -
useDefaultPredicateRegistry
private boolean useDefaultPredicateRegistryFlag which determines whether the default predicate registry will be used if one is not supplied explicitly. Defaults to true. -
activationCondition
Activation condition.
-
-
Constructor Details
-
AbstractMetadataResolver
public AbstractMetadataResolver()Constructor.
-
-
Method Details
-
getType
Gets the type of resolver for reporting or logging purposes.- Specified by:
getTypein interfaceMetadataResolver- Returns:
- resolver type
-
setType
Sets the type of this resolver for reporting/logging.- Parameters:
type- type to set- Since:
- 5.0.0
-
getMetricsBaseName
Get the base name for Metrics instrumentation.- Returns:
- the Metrics base name
- Since:
- 5.0.0
-
setMetricsBaseName
Set the base name for Metrics instrumentation.- Parameters:
baseName- the Metrics base name- Since:
- 5.0.0
-
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
validUntilattribute of the element and all its ancestral elements has not passed. Specific implementations may add additional constraints.- Specified by:
isRequireValidMetadatain interfaceMetadataResolver- Returns:
- whether the metadata returned by queries must be valid
-
setRequireValidMetadata
public void setRequireValidMetadata(boolean require) Sets whether the metadata returned by queries must be valid.- Specified by:
setRequireValidMetadatain interfaceMetadataResolver- Parameters:
require- whether the metadata returned by queries must be valid
-
getMetadataFilter
Gets the metadata filter applied to the metadata.- Specified by:
getMetadataFilterin interfaceMetadataResolver- Returns:
- the metadata filter applied to the metadata
-
setMetadataFilter
Sets the metadata filter applied to the metadata.- Specified by:
setMetadataFilterin interfaceMetadataResolver- Parameters:
newFilter- the metadata filter applied to the metadata
-
isFailFastInitialization
public boolean isFailFastInitialization()Gets whether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future.- Returns:
- whether problems during initialization should cause the provider to fail
-
setFailFastInitialization
public void setFailFastInitialization(boolean failFast) Sets whether problems during initialization should cause the provider to fail or go on without metadata. The assumption being that in most cases a provider will recover at some point in the future.- Parameters:
failFast- whether problems during initialization should cause the provider to fail
-
getParserPool
Gets the pool of parsers to use to parse XML.- Returns:
- pool of parsers to use to parse XML
-
isSatisfyAnyPredicates
public boolean isSatisfyAnyPredicates()Get the flag indicating whether resolved credentials may satisfy any predicates (i.e. connected by logical 'OR') or all predicates (connected by logical 'AND').Defaults to false.
- Returns:
- true if must satisfy all, false otherwise
-
setSatisfyAnyPredicates
public void setSatisfyAnyPredicates(boolean flag) Set the flag indicating whether resolved credentials may satisfy any predicates (i.e. connected by logical 'OR') or all predicates (connected by logical 'AND').Defaults to false.
- Parameters:
flag- true if must satisfy all, false otherwise
-
getCriterionPredicateRegistry
@NonnullAfterInit public CriterionPredicateRegistry<EntityDescriptor> getCriterionPredicateRegistry()Get the registry used in resolving predicates from criteria.- Returns:
- the effective registry instance used
-
isUseDefaultPredicateRegistry
public boolean isUseDefaultPredicateRegistry()Get the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.Defaults to true.
- Returns:
- true if should use default registry, false otherwise
-
setUseDefaultPredicateRegistry
public void setUseDefaultPredicateRegistry(boolean flag) Set the flag which determines whether the default predicate registry will be used if one is not supplied explicitly.Defaults to true.
- Parameters:
flag- true if should use default registry, false otherwise
-
getActivationCondition
Get an activation condition for this resolver.- Returns:
- activation condition
-
setActivationCondition
Set an activation condition for this resolver.- Parameters:
condition- condition to set
-
getUnmarshallerFactory
Get the XMLObject unmarshaller factory to use.- Returns:
- the unmarshaller factory instance to use
-
doInitialize
- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
doDestroy
protected void doDestroy()- Overrides:
doDestroyin classAbstractInitializableComponent
-
initMetadataResolver
Subclasses should override this method to perform any initialization logic necessary. Default implementation is a no-op.- Throws:
ComponentInitializationException- thrown if there is a problem initializing the provider
-
unmarshallMetadata
@Nonnull protected XMLObject unmarshallMetadata(@Nonnull InputStream metadataInput) throws UnmarshallingException Unmarshalls the metadata from the given stream. The stream is closed by this method and the returned metadata released its DOM representation.- Parameters:
metadataInput- the input reader to the metadata.- Returns:
- the unmarshalled metadata
- Throws:
UnmarshallingException- thrown if the metadata can no be unmarshalled
-
filterMetadata
Filters the given metadata.- Parameters:
metadata- the metadata to be filtered- Returns:
- the filtered metadata
- Throws:
FilterException- thrown if there is an error filtering the metadata
-
newFilterContext
Get a new instance ofMetadataFilterContextto be used when filtering metadata.This default implementation will just return an empty context. Subclasses would override to add contextual info specific to the implementation.
- Returns:
- the new filter context instance
-
releaseMetadataDOM
Releases the DOM representation from the metadata object.- Parameters:
metadata- the metadata object
-
isValid
Returns whether the given descriptor is valid. If valid metadata is not required this method always returns true.- Parameters:
descriptor- the descriptor to check- Returns:
- true if valid metadata is not required or the given descriptor is valid, false otherwise
-
lookupEntityID
@Nonnull protected List<EntityDescriptor> lookupEntityID(@Nonnull @NotEmpty String entityID) throws ResolverException Get list of descriptors matching an entityID.- Parameters:
entityID- entityID to lookup- Returns:
- a list of descriptors
- Throws:
ResolverException- if an error occurs
-
lookupIndexedEntityID
Lookup the specified entityID from the index. The returned list will be a copy of what is stored in the backing index, and is safe to be manipulated by callers.- Parameters:
entityID- the entityID to lookup- Returns:
- list copy of indexed entityID's, may be empty, will never be null
-
createNewBackingStore
Create a new backing store instance for EntityDescriptor data. Subclasses may override to return a more specialized subclass type. Note this method does not make the returned backing store the effective one in use. The caller is responsible for callingsetBackingStore(EntityBackingStore)to make it the effective instance in use.- Returns:
- the new backing store instance
-
getBackingStore
Get the EntityDescriptor backing store currently in use by the metadata resolver.- Returns:
- the current effective entity backing store
-
ensureBackingStore
Get the EntityDescriptor backing store currently in use by the metadata resolver, raising aConstraintViolationExceptionif null.- Returns:
- the current effective entity backing store
- Since:
- 5.0.0
-
setBackingStore
protected void setBackingStore(@Nonnull AbstractMetadataResolver.EntityBackingStore newBackingStore) Set the EntityDescriptor backing store currently in use by the metadata resolver.- Parameters:
newBackingStore- the new entity backing store
-
preProcessEntityDescriptor
protected void preProcessEntityDescriptor(@Nonnull EntityDescriptor entityDescriptor, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore) Pre-process the specified entity descriptor, updating the specified entity backing store instance as necessary.- Parameters:
entityDescriptor- the target entity descriptor to processbackingStore- the backing store instance to update
-
removeByEntityID
protected void removeByEntityID(@Nonnull String entityID, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore) Remove from the backing store all metadata for the entity with the given entity ID.- Parameters:
entityID- the entity ID of the metadata to removebackingStore- the backing store instance to update
-
indexEntityDescriptor
protected void indexEntityDescriptor(@Nonnull EntityDescriptor entityDescriptor, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore) Index the specified entity descriptor, updating the specified entity backing store instance as necessary.- Parameters:
entityDescriptor- the target entity descriptor to processbackingStore- the backing store instance to update
-
preProcessEntitiesDescriptor
protected void preProcessEntitiesDescriptor(@Nonnull EntitiesDescriptor entitiesDescriptor, @Nonnull AbstractMetadataResolver.EntityBackingStore backingStore) Pre-process the specified entities descriptor, updating the specified entity backing store instance as necessary.- Parameters:
entitiesDescriptor- the target entities descriptor to processbackingStore- the backing store instance to update
-
getLogPrefix
Return a prefix for logging messages for this component.- Returns:
- a string for insertion at the beginning of any log messages
-