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:
net.shibboleth.utilities.java.support.component.Component,net.shibboleth.utilities.java.support.component.DestructableComponent,net.shibboleth.utilities.java.support.component.InitializableComponent,org.opensaml.messaging.handler.MessageHandler
public class SAMLMetadataLookupHandler extends org.opensaml.messaging.handler.AbstractMessageHandlerHandler 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<org.opensaml.messaging.context.MessageContext,org.opensaml.saml.common.messaging.context.SAMLMetadataContext>copyContextStrategyOptional strategy for resolving an existing metadata context from which to copy data.private Class<? extends org.opensaml.saml.common.messaging.context.AbstractSAMLEntityContext>entityContextClassThe context class representing the SAML entity whose data is to be resolved.private org.slf4j.LoggerlogLogger.private org.opensaml.saml.metadata.resolver.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(org.opensaml.messaging.context.MessageContext messageContext)protected org.opensaml.saml.common.messaging.context.SAMLMetadataContextresolveExisting(org.opensaml.messaging.context.MessageContext messageContext, String entityID, QName role)Attempt to resolve an existingSAMLMetadataContextfrom which to copy.voidsetCopyContextStrategy(Function<org.opensaml.messaging.context.MessageContext,org.opensaml.saml.common.messaging.context.SAMLMetadataContext> strategy)Set the optional strategy for resolving an existing metadata context from which to copy data.voidsetEntityContextClass(Class<? extends org.opensaml.saml.common.messaging.context.AbstractSAMLEntityContext> clazz)Set the class type holding the SAML entity data.voidsetRoleDescriptorResolver(org.opensaml.saml.metadata.resolver.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
-
-
-
-
Field Detail
-
log
@Nonnull private final org.slf4j.Logger log
Logger.
-
metadataResolver
@NonnullAfterInit private org.opensaml.saml.metadata.resolver.RoleDescriptorResolver metadataResolver
Resolver used to look up SAML metadata.
-
entityContextClass
@Nonnull private Class<? extends org.opensaml.saml.common.messaging.context.AbstractSAMLEntityContext> entityContextClass
The context class representing the SAML entity whose data is to be resolved. Defaults to:SAMLPeerEntityContext.
-
copyContextStrategy
@Nullable private Function<org.opensaml.messaging.context.MessageContext,org.opensaml.saml.common.messaging.context.SAMLMetadataContext> copyContextStrategy
Optional strategy for resolving an existing metadata context from which to copy data.
-
-
Method Detail
-
setCopyContextStrategy
public void setCopyContextStrategy(@Nullable Function<org.opensaml.messaging.context.MessageContext,org.opensaml.saml.common.messaging.context.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 org.opensaml.saml.common.messaging.context.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 org.opensaml.saml.metadata.resolver.RoleDescriptorResolver resolver)Set theRoleDescriptorResolverto use.- Parameters:
resolver- the resolver to use
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException- Overrides:
doInitializein classnet.shibboleth.utilities.java.support.component.AbstractInitializableComponent- Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException
-
doInvoke
protected void doInvoke(@Nonnull org.opensaml.messaging.context.MessageContext messageContext) throws org.opensaml.messaging.handler.MessageHandlerException- Specified by:
doInvokein classorg.opensaml.messaging.handler.AbstractMessageHandler- Throws:
org.opensaml.messaging.handler.MessageHandlerException
-
resolveExisting
@Nullable protected org.opensaml.saml.common.messaging.context.SAMLMetadataContext resolveExisting(@Nonnull org.opensaml.messaging.context.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
-
-