Class CartOperationSensitiveDataRemovalFilter

java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
com.broadleafcommerce.cartoperation.web.filter.CartOperationSensitiveDataRemovalFilter
All Implemented Interfaces:
jakarta.servlet.Filter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.ServletContextAware

public class CartOperationSensitiveDataRemovalFilter extends org.springframework.web.filter.OncePerRequestFilter
An OncePerRequestFilter that intercepts the response and removes sensitive data before returning it.

For example, Cart may contain the baseCost information in its attributes and internal attributes, which should not be visible to customers. This filter will help prevent information leakage.

Since:
Cart Operation Service 2.3.0, Release Train 2.3.0
Author:
Sunny Yu
See Also:
  • Field Summary

    Fields inherited from class org.springframework.web.filter.OncePerRequestFilter

    ALREADY_FILTERED_SUFFIX

    Fields inherited from class org.springframework.web.filter.GenericFilterBean

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    CartOperationSensitiveDataRemovalFilter(com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartOperationSensitiveDataRemovalProperties cartSensitiveDataRemovalProperties)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doFilterInternal(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull jakarta.servlet.FilterChain filterChain)
     
    protected void
    modifyResponseBody(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull org.springframework.web.util.ContentCachingResponseWrapper responseWrapper)
     
    protected void
    removeFieldsRecursively(@NonNull com.fasterxml.jackson.databind.JsonNode node, @NonNull Collection<String> fieldNames)
     
    protected boolean
    shouldHandleRequest(@NonNull jakarta.servlet.http.HttpServletRequest request)
    Hook point to determine whether the given HttpServletRequest should be handled.

    Methods inherited from class org.springframework.web.filter.OncePerRequestFilter

    doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatch

    Methods inherited from class org.springframework.web.filter.GenericFilterBean

    addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CartOperationSensitiveDataRemovalFilter

      public CartOperationSensitiveDataRemovalFilter(com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartOperationSensitiveDataRemovalProperties cartSensitiveDataRemovalProperties)
  • Method Details

    • doFilterInternal

      protected void doFilterInternal(@NonNull @NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull @NonNull jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException
      Specified by:
      doFilterInternal in class org.springframework.web.filter.OncePerRequestFilter
      Throws:
      jakarta.servlet.ServletException
      IOException
    • shouldHandleRequest

      protected boolean shouldHandleRequest(@NonNull @NonNull jakarta.servlet.http.HttpServletRequest request)
      Hook point to determine whether the given HttpServletRequest should be handled.
    • modifyResponseBody

      protected void modifyResponseBody(@NonNull @NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull @NonNull org.springframework.web.util.ContentCachingResponseWrapper responseWrapper) throws IOException
      Throws:
      IOException
    • removeFieldsRecursively

      protected void removeFieldsRecursively(@NonNull @NonNull com.fasterxml.jackson.databind.JsonNode node, @NonNull @NonNull Collection<String> fieldNames)