Package org.opensaml.saml.common.binding.impl

# Class SAMLProtocolAndRoleHandler

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.handler.AbstractMessageHandler
org.opensaml.saml.common.binding.impl.SAMLProtocolAndRoleHandler

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `MessageHandler`

public class SAMLProtocolAndRoleHandler extends AbstractMessageHandler
SAML `MessageHandler` that attaches protocol and role information to a message context via `SAMLProtocolContext` and an instance of `AbstractSAMLEntityContext` objects. The entity context class is configurable and defaults to `SAMLPeerEntityContext`.

A profile flow would typically run this handler after message decoding occurs, to bootstrap subsequent handlers.

## Field Summary

Fields
Modifier and Type
Field
Description
`private ContextDataLookupFunction<MessageContext,? extends BaseContext>`
`copyContextLookup`
Optional lookup function for a context from which to copy the protocol and role data, for example from a parent operation context.
`private Class<? extends AbstractSAMLEntityContext>`
`entityContextClass`
The context class representing the SAML entity for whom data is to be attached.
`private QName`
`peerRole`
Role type to add to context.
`private String`
`samlProtocol`
Protocol value to add to context.

## Constructor Summary

Constructors
Constructor
Description
`SAMLProtocolAndRoleHandler()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`doInitialize()`
`protected void`
`doInvoke(MessageContext messageContext)`
Performs the handler logic.
`void`
`setCopyContextLookup(ContextDataLookupFunction<MessageContext,? extends BaseContext> lookup)`
Set the optional lookup function for a context from which to copy the protocol and role data, for example from a parent operation context.
`void`
`setEntityContextClass(Class<? extends AbstractSAMLEntityContext> clazz)`
Set the class type holding the SAML entity data.
`void`
`setProtocol(String protocol)`
Set the protocol constant to attach.
`void`
`setRole(QName role)`
Set the operational role to attach.

### Methods inherited from class org.opensaml.messaging.handler.AbstractMessageHandler

`doPostInvoke, doPostInvoke, doPreInvoke, getActivationCondition, getLogPrefix, invoke, isPreInvokeCalled, setActivationCondition`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, 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.shared.component.InitializableComponent

`initialize, isInitialized`

## Field Details

### samlProtocol

@NonnullAfterInit @NotEmpty private String samlProtocol
Protocol value to add to context.

### peerRole

@NonnullAfterInit private QName peerRole
Role type to add to context.

### entityContextClass

@Nonnull private Class<? extends AbstractSAMLEntityContext> entityContextClass
The context class representing the SAML entity for whom data is to be attached. Defaults to: `SAMLPeerEntityContext`.

### copyContextLookup

@Nullable private ContextDataLookupFunction<MessageContext,? extends BaseContext> copyContextLookup
Optional lookup function for a context from which to copy the protocol and role data, for example from a parent operation context.

## Constructor Details

### SAMLProtocolAndRoleHandler

public SAMLProtocolAndRoleHandler()

## Method Details

### setCopyContextLookup

public void setCopyContextLookup(@Nullable ContextDataLookupFunction<MessageContext,? extends BaseContext> lookup)
Set the optional lookup function for a context from which to copy the protocol and role data, for example from a parent operation context.

Parameters:
  `lookup` - the lookup function, may be null

### 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

### setProtocol

public void setProtocol(@Nonnull @NotEmpty String protocol)
Set the protocol constant to attach.

Parameters:
  `protocol` - the protocol constant to set

### setRole

public void setRole(@Nonnull QName role)
Set the operational role to attach.

Parameters:
  `role` - the operational role to set

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractInitializableComponent`
Throws:
  `ComponentInitializationException`

### doInvoke

protected void doInvoke(@Nonnull MessageContext messageContext) throws MessageHandlerException
Performs the handler logic.

Specified by:
  `doInvoke` in class `AbstractMessageHandler`
Parameters:
  `messageContext` - the message context on which to invoke the handler
Throws:
  `MessageHandlerException` - if there is an error invoking the handler on the message context