Class AbstractProfileAction
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.profile.action.AbstractProfileAction
-
- org.opensaml.profile.action.AbstractConditionalProfileAction
-
- net.shibboleth.idp.profile.AbstractProfileAction
-
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
- Direct Known Subclasses:
AbstractProfileInterceptorAction,ScriptedAction
@ThreadSafe public abstract class AbstractProfileAction extends AbstractConditionalProfileAction implements Action, MessageSource, MessageSourceAware
Base class for Spring-aware profile actions.This base class takes care of the following:
- retrieving the
ProfileRequestContextfrom the current request environment - populating the SWF
RequestContextinto the profile context tree - starting or stopping any timers as instructed by a
MetricContextin the tree
Action implementations may override
doExecute(RequestContext, ProfileRequestContext)if they require SWF functionality, but most should overrideAbstractProfileAction.doExecute(ProfileRequestContext)instead.
-
-
Field Summary
Fields Modifier and Type Field Description private org.slf4j.LoggerlogClass logger.private MessageSourcemessageSourceMessageSource injected by Spring, typically the parent ApplicationContext itself.private Function<RequestContext,ProfileRequestContext>profileContextLookupStrategyStrategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.
-
Constructor Summary
Constructors Constructor Description AbstractProfileAction()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EventdoExecute(RequestContext springRequestContext, ProfileRequestContext profileRequestContext)Spring-aware actions can override this method to fully control the execution of an Action by the Web Flow engine.Eventexecute(RequestContext springRequestContext)StringgetMessage(String code, Object[] args, String defaultMessage, Locale locale)StringgetMessage(String code, Object[] args, Locale locale)StringgetMessage(MessageSourceResolvable resolvable, Locale locale)Function<RequestContext,ProfileRequestContext>getProfileContextLookupStrategy()Get the strategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.protected RequestContextgetRequestContext(ProfileRequestContext profileRequestContext)Gets the SpringRequestContextfrom aSpringRequestContextstored in the context tree.protected EventgetResult(ProfileAction action, ProfileRequestContext profileRequestContext)Examines the profile context for an event to return, or signals a successful outcome if noEventContextis located; the EventContext will be removed upon completion.voidsetMessageSource(MessageSource source)voidsetProfileContextLookupStrategy(Function<RequestContext,ProfileRequestContext> strategy)Set the strategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.-
Methods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
doPreExecute, getActivationCondition, setActivationCondition
-
Methods inherited from class org.opensaml.profile.action.AbstractProfileAction
doExecute, doPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletResponse, getLogPrefix, setHttpServletRequest, setHttpServletResponse
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, doInitialize, 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
Class logger.
-
profileContextLookupStrategy
@Nonnull private Function<RequestContext,ProfileRequestContext> profileContextLookupStrategy
Strategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.
-
messageSource
@Nonnull private MessageSource messageSource
MessageSource injected by Spring, typically the parent ApplicationContext itself.
-
-
Constructor Detail
-
AbstractProfileAction
public AbstractProfileAction()
Constructor. Initializes the ID of this action to the class name and callssetProfileContextLookupStrategy(Function)withWebflowRequestContextProfileRequestContextLookup.
-
-
Method Detail
-
getProfileContextLookupStrategy
@Nonnull public Function<RequestContext,ProfileRequestContext> getProfileContextLookupStrategy()
Get the strategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.- Returns:
- lookup strategy
-
setProfileContextLookupStrategy
public void setProfileContextLookupStrategy(@Nonnull Function<RequestContext,ProfileRequestContext> strategy)Set the strategy used to lookup theProfileRequestContextfrom a given WebFlowRequestContext.- Parameters:
strategy- lookup strategy
-
execute
@Nonnull public Event execute(@Nonnull RequestContext springRequestContext)
-
doExecute
@Nonnull protected Event doExecute(@Nonnull RequestContext springRequestContext, @Nonnull ProfileRequestContext profileRequestContext)
Spring-aware actions can override this method to fully control the execution of an Action by the Web Flow engine.Alternatively they may override
AbstractProfileAction.doExecute(ProfileRequestContext)and access Spring information via aSpringRequestContextattached to the profile request context.The default implementation attaches the Spring Web Flow request context to the profile request context tree to "narrow" the execution signature to the basic OpenSAML
ProfileActioninterface. After execution, anEventContextis sought, and used to return a result back to the Web Flow engine. If no context exists, a "proceed" event is signaled.- Parameters:
springRequestContext- the Spring request contextprofileRequestContext- a profile request context- Returns:
- a Web Flow event produced by the action
-
getResult
@Nonnull protected Event getResult(@Nonnull ProfileAction action, @Nonnull ProfileRequestContext profileRequestContext)
Examines the profile context for an event to return, or signals a successful outcome if noEventContextis located; the EventContext will be removed upon completion.The EventContext must contain a Spring Web Flow
Eventor aString. Any other type of context data will be ignored.- Parameters:
action- the action signaling the eventprofileRequestContext- the profile request context to examine- Returns:
- an event based on the profile request context, or "proceed"
-
setMessageSource
public void setMessageSource(MessageSource source)
- Specified by:
setMessageSourcein interfaceMessageSourceAware
-
getMessage
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
- Specified by:
getMessagein interfaceMessageSource
-
getMessage
public String getMessage(String code, Object[] args, Locale locale)
- Specified by:
getMessagein interfaceMessageSource
-
getMessage
public String getMessage(MessageSourceResolvable resolvable, Locale locale)
- Specified by:
getMessagein interfaceMessageSource
-
getRequestContext
@Nullable protected RequestContext getRequestContext(@Nonnull ProfileRequestContext profileRequestContext)
Gets the SpringRequestContextfrom aSpringRequestContextstored in the context tree.- Parameters:
profileRequestContext- Profile request context.- Returns:
- Spring request context.
-
-