Class TokenSessionStoreInterceptor
- All Implemented Interfaces:
Serializable,ConditionalInterceptor,Interceptor
This interceptor builds off of the TokenInterceptor, providing advanced logic for handling invalid tokens.
Unlike the normal token interceptor, this interceptor will attempt to provide intelligent fail-over in the event of
multiple requests using the same session. That is, it will block subsequent requests until the first request is
complete, and then instead of returning the invalid.token code, it will attempt to display the same response
that the original, valid action invocation would have displayed if no multiple requests were submitted in the first
place.
NOTE: As this method extends off MethodFilterInterceptor, it is capable of
deciding if it is applicable only to selective methods in the action class. See
MethodFilterInterceptor for more info.
Interceptor parameters:
- None
Extending the interceptor:
There are no known extension points for this interceptor.
Example code:
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="tokenSession/>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>
<-- In this case, myMethod of the action class will not
get checked for invalidity of token -->
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="tokenSession>
<param name="excludeMethods">myMethod</param>
</interceptor-ref name="tokenSession>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>
- See Also:
-
Field Summary
Fields inherited from class org.apache.struts2.interceptor.TokenInterceptor
INVALID_TOKEN_CODEFields inherited from class org.apache.struts2.interceptor.MethodFilterInterceptor
excludeMethods, includeMethods -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringhandleInvalidToken(ActionInvocation invocation) Handles processing of invalid tokens.protected StringhandleToken(ActionInvocation invocation) protected StringhandleValidToken(ActionInvocation invocation) Handles processing of valid tokens.Methods inherited from class org.apache.struts2.interceptor.TokenInterceptor
doIntercept, getErrorMessage, setTextProviderFactoryMethods inherited from class org.apache.struts2.interceptor.MethodFilterInterceptor
applyInterceptor, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethodsMethods inherited from class org.apache.struts2.interceptor.AbstractInterceptor
destroy, init, setDisabled, shouldIntercept
-
Constructor Details
-
TokenSessionStoreInterceptor
public TokenSessionStoreInterceptor()
-
-
Method Details
-
handleToken
- Overrides:
handleTokenin classTokenInterceptor- Throws:
Exception
-
handleInvalidToken
Handles processing of invalid tokens. If a previously stored invocation is available, the method will attempt to return and render its result. Otherwise it will return INVALID_TOKEN_CODE. Note: Because a stored (previously completed) invocation's PageContext will be closed, this method must replace the stored PageContext with the current invocation's one (or a null). SeeInvocationSessionStore.loadInvocation(String key, String token)for details.- Overrides:
handleInvalidTokenin classTokenInterceptor- Parameters:
invocation-- Returns:
- Throws:
Exception
-
handleValidToken
Handles processing of valid tokens. Stores the current invocation for later use by . SeeInvocationSessionStore.storeInvocation(String key, String token, ActionInvocation invocation)for details.- Overrides:
handleValidTokenin classTokenInterceptor- Parameters:
invocation-- Returns:
- Throws:
Exception
-