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_SUFFIXFields inherited from class org.springframework.web.filter.GenericFilterBean
logger -
Constructor Summary
ConstructorsConstructorDescriptionCartOperationSensitiveDataRemovalFilter(com.fasterxml.jackson.databind.ObjectMapper objectMapper, CartOperationSensitiveDataRemovalProperties cartSensitiveDataRemovalProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilterInternal(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull jakarta.servlet.http.HttpServletResponse response, @NonNull jakarta.servlet.FilterChain filterChain) protected voidmodifyResponseBody(@NonNull jakarta.servlet.http.HttpServletRequest request, @NonNull org.springframework.web.util.ContentCachingResponseWrapper responseWrapper) protected voidremoveFieldsRecursively(@NonNull com.fasterxml.jackson.databind.JsonNode node, @NonNull Collection<String> fieldNames) protected booleanshouldHandleRequest(@NonNull jakarta.servlet.http.HttpServletRequest request) Hook point to determine whether the givenHttpServletRequestshould be handled.Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, doFilterNestedErrorDispatch, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStarted, shouldNotFilter, shouldNotFilterAsyncDispatch, shouldNotFilterErrorDispatchMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
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:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
jakarta.servlet.ServletExceptionIOException
-
shouldHandleRequest
protected boolean shouldHandleRequest(@NonNull @NonNull jakarta.servlet.http.HttpServletRequest request) Hook point to determine whether the givenHttpServletRequestshould 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)
-