Class SecurityTokenHandler
java.lang.Object
fr.paris.lutece.portal.service.security.SecurityTokenHandler
Handles the Security token related to the SecurityTokenFilter.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddSecurityToken(String strSource, Object model) Adds the hidden field to forms located in the given template data.voidaddSessionTokenValue(jakarta.servlet.http.HttpServletRequest request, Map<String, Object> model) Adds the session security token for confirm type actions (SiteMessageHandler / AdminMessageJspBean).voidhandle(jakarta.servlet.http.HttpServletRequest request) Activates the token handling on the request.voidhandleToken(jakarta.servlet.http.HttpServletRequest request, MvcEvent.ControllerInvocationType invocationType, Method method) Handles the generation and storage of the security token.voidObserves controller invocations and handles token validation for selected invocation types (ACTION, VIEW, DEFAULT_VIEW).voidregisterActions(String strName, Method[] methods) Registers disabled action methods from XPage or MVCAdminJspBeanvoidregisterAdminControllers(jakarta.servlet.ServletContext context) Registers the actions of every back office MVC controller with the security token enabled, at application startup, so that the token is checked from the first request, before the controller has ever been displayed.resolveTokenValue(jakarta.servlet.http.HttpServletRequest request) Resolves security token value from the request.booleanshouldNotFilter(jakarta.servlet.http.HttpServletRequest request) Checks if the request should validate the security token.booleanValidates the token for the given request.
-
Field Details
-
MARK_CSRF_TOKEN
- See Also:
-
-
Constructor Details
-
SecurityTokenHandler
public SecurityTokenHandler()
-
-
Method Details
-
registerAdminControllers
public void registerAdminControllers(@Observes @Initialized(jakarta.enterprise.context.ApplicationScoped.class) jakarta.servlet.ServletContext context) Registers the actions of every back office MVC controller with the security token enabled, at application startup, so that the token is checked from the first request, before the controller has ever been displayed.- Parameters:
context- The servlet context
-
registerActions
Registers disabled action methods from XPage or MVCAdminJspBean -
handle
public void handle(jakarta.servlet.http.HttpServletRequest request) Activates the token handling on the request.- Parameters:
request- The request
-
shouldNotFilter
public boolean shouldNotFilter(jakarta.servlet.http.HttpServletRequest request) Checks if the request should validate the security token.- Parameters:
request- The request- Returns:
- True if the request should be skipped from the SecurityTokenFilter validation, false otherwise.
-
handleToken
public void handleToken(jakarta.servlet.http.HttpServletRequest request, MvcEvent.ControllerInvocationType invocationType, Method method) Handles the generation and storage of the security token.- Parameters:
request- The requestinvocationType- The invocation typemethods- The MVC methods
-
resolveTokenValue
Resolves security token value from the request.- Parameters:
request- The request- Returns:
- The security token value
-
addSessionTokenValue
public void addSessionTokenValue(jakarta.servlet.http.HttpServletRequest request, Map<String, Object> model) Adds the session security token for confirm type actions (SiteMessageHandler / AdminMessageJspBean).- Parameters:
request- The requestmodel- The model
-
validate
Validates the token for the given request.- Parameters:
request- The requeststrAction- The MVC action- Returns:
- True if the token was valid.
-
addSecurityToken
Adds the hidden field to forms located in the given template data.- Parameters:
strSource- The template data.model- The model- Returns:
- The updated template data.
-
onControllerInvocation
Observes controller invocations and handles token validation for selected invocation types (ACTION, VIEW, DEFAULT_VIEW).- Parameters:
event- the controller event
-