Class SAMLMetadataLookupHandler
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.handler.AbstractMessageHandler
-
- org.opensaml.saml.common.binding.impl.SAMLMetadataLookupHandler
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,MessageHandler
public class SAMLMetadataLookupHandler extends AbstractMessageHandler
Handler for inbound SAML protocol messages that attempts to locate SAML metadata for a SAML entity, and attaches it as aSAMLMetadataContextchild of a pre-existing concrete instance ofAbstractSAMLEntityContext.The entity context class is configurable and defaults to
SAMLPeerEntityContext. The handler will no-op in the absence of an existingAbstractSAMLEntityContextchild of the message context with non-null values for both entityID and role.If the optional copy strategy is configured via
setCopyContextStrategy(Function), and if that lookup finds an existing metadata context with compatible data (matching entityID and role), then its data will be re-used.Otherwise an attempt to resolve metadata will be performed with the configured
RoleDescriptorResolver. A protocol from aSAMLProtocolContextwill be added to the lookup, if available.
-
-
Field Summary
Fields Modifier and Type Field Description private Function<MessageContext,SAMLMetadataContext>copyContextStrategyOptional strategy for resolving an existing metadata context from which to copy data.private Class<? extends AbstractSAMLEntityContext>entityContextClassThe context class representing the SAML entity whose data is to be resolved.private org.slf4j.LoggerlogLogger.private RoleDescriptorResolvermetadataResolverResolver used to look up SAML metadata.
-
Constructor Summary
Constructors Constructor Description SAMLMetadataLookupHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoInitialize()protected voiddoInvoke(MessageContext messageContext)protected SAMLMetadataContextresolveExisting(MessageContext messageContext, String entityID, QName role)Attempt to resolve an existingSAMLMetadataContextfrom which to copy.voidsetCopyContextStrategy(Function<MessageContext,SAMLMetadataContext> strategy)Set the optional strategy for resolving an existing metadata context from which to copy data.voidsetEntityContextClass(Class<? extends AbstractSAMLEntityContext> clazz)Set the class type holding the SAML entity data.voidsetRoleDescriptorResolver(RoleDescriptorResolver resolver)Set theRoleDescriptorResolverto use.-
Methods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler
doPostInvoke, doPostInvoke, doPreInvoke, getActivationCondition, getLogPrefix, invoke, setActivationCondition
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, 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.InitializableComponent
initialize, isInitialized
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Logger.
-
metadataResolver
@NonnullAfterInit private RoleDescriptorResolver metadataResolver
Resolver used to look up SAML metadata.
-
entityContextClass
@Nonnull private Class<? extends AbstractSAMLEntityContext> entityContextClass
The context class representing the SAML entity whose data is to be resolved. Defaults to:SAMLPeerEntityContext.
-
copyContextStrategy
@Nullable private Function<MessageContext,SAMLMetadataContext> copyContextStrategy
Optional strategy for resolving an existing metadata context from which to copy data.
-
-
Method Detail
-
setCopyContextStrategy
public void setCopyContextStrategy(@Nullable Function<MessageContext,SAMLMetadataContext> strategy)Set the optional strategy for resolving an existing metadata context from which to copy data.- Parameters:
strategy- the strategy function
-
setEntityContextClass
public void setEntityContextClass(@Nonnull Class<? extends AbstractSAMLEntityContext> clazz)Set the class type holding the SAML entity data.Defaults to:
SAMLPeerEntityContext.- Parameters:
clazz- the entity context class type
-
setRoleDescriptorResolver
public void setRoleDescriptorResolver(@Nonnull RoleDescriptorResolver resolver)Set theRoleDescriptorResolverto use.- Parameters:
resolver- the resolver to use
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doInvoke
protected void doInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException- Specified by:
doInvokein classAbstractMessageHandler- Throws:
MessageHandlerException
-
resolveExisting
@Nullable protected SAMLMetadataContext resolveExisting(@Nonnull MessageContext messageContext, @Nonnull String entityID, @Nonnull QName role)
Attempt to resolve an existingSAMLMetadataContextfrom which to copy.The returned context will always be a fresh parent-less instance, suitable for the caller to directly store in the current message context.
- Parameters:
messageContext- the current message contextentityID- the entityID against which to matchrole- the entity role against which to match- Returns:
- a new instance of
SAMLMetadataContext, or null if one can not be resolved
-
-