Class SecurityTokenHandler

java.lang.Object
fr.paris.lutece.portal.service.security.SecurityTokenHandler

@ApplicationScoped public class SecurityTokenHandler extends Object
Handles the Security token related to the SecurityTokenFilter.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    addSecurityToken(String strSource, Object model)
    Adds the hidden field to forms located in the given template data.
    void
    addSessionTokenValue(jakarta.servlet.http.HttpServletRequest request, Map<String,Object> model)
    Adds the session security token for confirm type actions (SiteMessageHandler / AdminMessageJspBean).
    void
    handle(jakarta.servlet.http.HttpServletRequest request)
    Activates the token handling on the request.
    void
    handleToken(jakarta.servlet.http.HttpServletRequest request, MvcEvent.ControllerInvocationType invocationType, Method method)
    Handles the generation and storage of the security token.
    void
    Observes controller invocations and handles token validation for selected invocation types (ACTION, VIEW, DEFAULT_VIEW).
    void
    registerActions(String strName, Method[] methods)
    Registers disabled action methods from XPage or MVCAdminJspBean
    void
    registerAdminControllers(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.
    boolean
    shouldNotFilter(jakarta.servlet.http.HttpServletRequest request)
    Checks if the request should validate the security token.
    boolean
    validate(jakarta.servlet.http.HttpServletRequest request, String strAction)
    Validates the token for the given request.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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

      public void registerActions(String strName, Method[] methods)
      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 request
      invocationType - The invocation type
      methods - The MVC methods
    • resolveTokenValue

      public String resolveTokenValue(jakarta.servlet.http.HttpServletRequest request)
      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 request
      model - The model
    • validate

      public boolean validate(jakarta.servlet.http.HttpServletRequest request, String strAction)
      Validates the token for the given request.
      Parameters:
      request - The request
      strAction - The MVC action
      Returns:
      True if the token was valid.
    • addSecurityToken

      public static String addSecurityToken(String strSource, Object model)
      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

      public void onControllerInvocation(@Observes BeforeControllerEvent event)
      Observes controller invocations and handles token validation for selected invocation types (ACTION, VIEW, DEFAULT_VIEW).
      Parameters:
      event - the controller event