Class CustomizedForwardedHeaderFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.frankframework.lifecycle.servlets.CustomizedForwardedHeaderFilter
- 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 CustomizedForwardedHeaderFilter
extends org.springframework.web.filter.OncePerRequestFilter
Customized version of the original class ForwardedHeaderFilter in Spring Framework.
Extract values from "Forwarded" and "X-Forwarded-*" headers, wrap the request
and response, and make them reflect the client-originated protocol and
address in the following methods:
getServerName()getServerPort()getScheme()isSecure()sendRedirect(String).
There are security considerations for forwarded headers since an application cannot know if the headers were added by a proxy, as intended, or by a malicious client. This is why a proxy at the boundary of trust should be configured to remove untrusted Forwarded headers that come from the outside.
- Since:
- 4.3
- Author:
- Rossen Stoyanchev, EddĂș MelĂ©ndez, Rob Winch, Brian Clozel
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilterInternal(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) protected voiddoFilterNestedErrorDispatch(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) protected StringformatRequest(jakarta.servlet.http.HttpServletRequest request) Format the request for logging purposes including HTTP method and URL.protected booleanshouldNotFilter(jakarta.servlet.http.HttpServletRequest request) protected booleanprotected booleanMethods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, isAsyncDispatch, isAsyncStartedMethods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Constructor Details
-
CustomizedForwardedHeaderFilter
public CustomizedForwardedHeaderFilter(boolean allowForwardedHeadersPassthrough)
-
-
Method Details
-
shouldNotFilter
protected boolean shouldNotFilter(@Nonnull jakarta.servlet.http.HttpServletRequest request) - Overrides:
shouldNotFilterin classorg.springframework.web.filter.OncePerRequestFilter
-
shouldNotFilterAsyncDispatch
protected boolean shouldNotFilterAsyncDispatch()- Overrides:
shouldNotFilterAsyncDispatchin classorg.springframework.web.filter.OncePerRequestFilter
-
shouldNotFilterErrorDispatch
protected boolean shouldNotFilterErrorDispatch()- Overrides:
shouldNotFilterErrorDispatchin classorg.springframework.web.filter.OncePerRequestFilter
-
doFilterInternal
protected void doFilterInternal(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response, @Nonnull jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException - Specified by:
doFilterInternalin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
jakarta.servlet.ServletExceptionIOException
-
formatRequest
Format the request for logging purposes including HTTP method and URL.- Parameters:
request- the request to format- Returns:
- the String to display, never empty or
null
-
doFilterNestedErrorDispatch
protected void doFilterNestedErrorDispatch(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response, @Nonnull jakarta.servlet.FilterChain filterChain) throws jakarta.servlet.ServletException, IOException - Overrides:
doFilterNestedErrorDispatchin classorg.springframework.web.filter.OncePerRequestFilter- Throws:
jakarta.servlet.ServletExceptionIOException
-