Class AbstractMetadataProvider
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
se.swedenconnect.opensaml.saml2.metadata.provider.AbstractMetadataProvider
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MetadataProvider
- Direct Known Subclasses:
CompositeMetadataProvider,FilesystemMetadataProvider,HTTPMetadataProvider,MDQMetadataProvider,ProxyMetadataProvider,StaticMetadataProvider
public abstract class AbstractMetadataProvider
extends AbstractInitializableComponent
implements MetadataProvider
Abstract base class for the
MetadataProvider interface.- Author:
- Martin Lindström (martin@idsec.se)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classIterates over EntitiesDescriptor or EntityDescriptor. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MetadataFilterCreates the filter(s) that this instance should be configured with.protected abstract voidcreateMetadataResolver(boolean requireValidMetadata, boolean failFastInitialization, MetadataFilter filter) Creates the specificMetadataResolverinstance for the provider implementation.protected abstract voidDestroys the metadata resolver.protected voidprotected final voidgetEntityDescriptor(String entityID) Returns the entity descriptor identified by the given entityID.getEntityDescriptor(String entityID, QName role) Returns the entity descriptor identified by the given entityID and given role.Utility method that returns a list of entity descriptors for Identity Providers found in the metadata.Returns the time the currently available metadata was last updated.Returns the XML element making up the metadata for the federation.Returns the DOM element making up the metadata for the federation.Utility method that returns a list of entity descriptors for Service Providers found in the metadata.Gets the certificate that is to be used when verifying the signature on downloaded metadata.protected abstract voidInitializes the metadata resolver.iterator()Returns an iterator for all entity descriptors held by the provider.Returns an iterator for all entity descriptors having the given role.voidrefresh()Refresh the metadata handled by the provider.voidsetExclusionPredicates(List<Predicate<EntityDescriptor>> exclusionPredicates) Assigns a list of exclusion predicates that will be applied to downloaded metadata.voidsetFailFastInitialization(boolean failFast) Sets whether problems during initialization should cause the provider to fail or go on without metadata.voidsetInclusionPredicates(List<Predicate<EntityDescriptor>> inclusionPredicates) Assigns a list of inclusion predicates that will be applied to downloaded metadata.voidsetKeepOnlySpAndIdps(boolean keepOnlySpAndIdps) Tells whether we should keep only SP and IdP role descriptors.protected voidsetMetadata(XMLObject metadata) Assigns the metadata that was downloaded.voidsetPerformSchemaValidation(boolean performSchemaValidation) Assigns whether XML schema validation should be performed on downloaded metadata.voidsetRequireValidMetadata(boolean requireValidMetadata) Sets whether the metadata returned by queries must be valid.voidsetSignatureVerificationCertificate(X509Certificate signatureVerificationCertificate) Assigns the certificate that is to be used when verifying the signature on downloaded metadata.voidsetSignatureVerificationCertificates(List<X509Certificate> signatureVerificationCertificates) Assigns the certificates that are to be used when verifying the signature on downloaded metadata.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, 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.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitializedMethods inherited from interface se.swedenconnect.opensaml.saml2.metadata.provider.MetadataProvider
getID, getMetadataResolver
-
Constructor Details
-
AbstractMetadataProvider
public AbstractMetadataProvider()
-
-
Method Details
-
getMetadata
Returns the XML element making up the metadata for the federation. This element is either anEntityDescriptoror anEntitiesDescriptor.- Specified by:
getMetadatain interfaceMetadataProvider- Returns:
- an XML element
-
getMetadataDOM
Returns the DOM element making up the metadata for the federation.- Specified by:
getMetadataDOMin interfaceMetadataProvider- Returns:
- a DOM element
- Throws:
MarshallingException- for XML marshalling errors
-
getLastUpdate
Returns the time the currently available metadata was last updated.- Specified by:
getLastUpdatein interfaceMetadataProvider- Returns:
- time when the currently metadata was last updated, or null if no metadata has been successfully loaded
-
refresh
Refresh the metadata handled by the provider.An implementation that does not support refresh should implement this operation as a no-op. Implementations that do support refresh of metadata should typically be either
synchronizedor make use other locking mechanisms to protect against concurrent access.- Specified by:
refreshin interfaceMetadataProvider- Throws:
ResolverException- if the refresh operation was unsuccessful
-
iterator
Returns an iterator for all entity descriptors held by the provider.- Specified by:
iteratorin interfaceMetadataProvider- Returns:
- an iterator for all entity descriptors
-
iterator
Returns an iterator for all entity descriptors having the given role.To list all IdP:s and SP:s do:
idps = provider.iterator(IDPSSODescriptor.DEFAULT_ELEMENT_NAME); sps = provider.iterator(SPSSODescriptor.DEFAULT_ELEMENT_NAME);- Specified by:
iteratorin interfaceMetadataProvider- Parameters:
role- role descriptor- Returns:
- an iterator for all matching entity descriptors
- See Also:
-
getEntityDescriptor
Returns the entity descriptor identified by the given entityID.- Specified by:
getEntityDescriptorin interfaceMetadataProvider- Parameters:
entityID- the unique entityID for the entry- Returns:
- an entity descriptor or null if no entry is found
- Throws:
ResolverException- for underlying metadata errors
-
getEntityDescriptor
Returns the entity descriptor identified by the given entityID and given role.- Specified by:
getEntityDescriptorin interfaceMetadataProvider- Parameters:
entityID- the entity IDrole- the role descriptor- Returns:
- an entity descriptor or null if no matching entry is found
- Throws:
ResolverException- for underlying metadata errors
-
getIdentityProviders
Utility method that returns a list of entity descriptors for Identity Providers found in the metadata.- Specified by:
getIdentityProvidersin interfaceMetadataProvider- Returns:
- a list of entity descriptors
- Throws:
ResolverException- for metadata errors
-
getServiceProviders
Utility method that returns a list of entity descriptors for Service Providers found in the metadata.- Specified by:
getServiceProvidersin interfaceMetadataProvider- Returns:
- a list of entity descriptors
- Throws:
ResolverException- for metadata errors
-
setMetadata
Assigns the metadata that was downloaded.- Parameters:
metadata- metadata object
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
createFilter
Creates the filter(s) that this instance should be configured with.- Returns:
- a metadata filter
- Throws:
ComponentInitializationException- if filters fails to initialize
-
doDestroy
protected void doDestroy()- Overrides:
doDestroyin classAbstractInitializableComponent
-
createMetadataResolver
protected abstract void createMetadataResolver(boolean requireValidMetadata, boolean failFastInitialization, MetadataFilter filter) throws ResolverException Creates the specificMetadataResolverinstance for the provider implementation.The
filterparameter is aMetadataFilterthat must be installed for the resolver. Any other filters that should be installed by the specific instance should be placed last in a filter chain.- Parameters:
requireValidMetadata- should be passed intoMetadataResolver.setRequireValidMetadata(boolean)failFastInitialization- should be passed intoAbstractMetadataResolver.setFailFastInitialization(boolean)(if applicable)filter- filter that must be installed for the resolver- Throws:
ResolverException- for errors creating the resolver
-
initializeMetadataResolver
Initializes the metadata resolver.- Throws:
ComponentInitializationException- for initialization errors
-
destroyMetadataResolver
protected abstract void destroyMetadataResolver()Destroys the metadata resolver. -
setRequireValidMetadata
public void setRequireValidMetadata(boolean requireValidMetadata) Sets whether the metadata returned by queries must be valid.- Parameters:
requireValidMetadata- whether the metadata returned by queries must be valid
-
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
-
setSignatureVerificationCertificate
Assigns the certificate that is to be used when verifying the signature on downloaded metadata. If this attribute is assigned the provider is configured to expect a valid signature on downloaded metadata.- Parameters:
signatureVerificationCertificate- the certificate to assign
-
setSignatureVerificationCertificates
public void setSignatureVerificationCertificates(List<X509Certificate> signatureVerificationCertificates) Assigns the certificates that are to be used when verifying the signature on downloaded metadata. If this attribute is assigned the provider is configured to expect a valid signature on downloaded metadata.The reason that more than one certificate may be assigned is that we want to be able to handle signing certificate updates in a smooth way.
- Parameters:
signatureVerificationCertificates- the certificates to assign
-
getSignatureVerificationCertificates
Gets the certificate that is to be used when verifying the signature on downloaded metadata.- Returns:
- the certificates or null
-
setPerformSchemaValidation
public void setPerformSchemaValidation(boolean performSchemaValidation) Assigns whether XML schema validation should be performed on downloaded metadata.- Parameters:
performSchemaValidation- whether schema validation should be performed
-
setKeepOnlySpAndIdps
public void setKeepOnlySpAndIdps(boolean keepOnlySpAndIdps) Tells whether we should keep only SP and IdP role descriptors. The default is true.- Parameters:
keepOnlySpAndIdps- whether to keep only SPs and IdPs.
-
setInclusionPredicates
Assigns a list of inclusion predicates that will be applied to downloaded metadata.- Parameters:
inclusionPredicates- predicates- See Also:
-
setExclusionPredicates
Assigns a list of exclusion predicates that will be applied to downloaded metadata.- Parameters:
exclusionPredicates- predicates- See Also:
-