Class WMTokenBasedPreAuthenticatedProcessingFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
com.wavemaker.runtime.security.filter.WMTokenBasedPreAuthenticatedProcessingFilter
- 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.ApplicationEventPublisherAware,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public class WMTokenBasedPreAuthenticatedProcessingFilter
extends org.springframework.web.filter.GenericFilterBean
implements org.springframework.context.ApplicationEventPublisherAware
WMAppTokenBasedPreAuthenticatedProcessingFilter for processing filters that handle pre-authenticated authentication requests, where it is assumed
that the principal has already been authenticated by an external system.
The purpose is then only to extract the necessary information on the principal from the incoming request query param, rather
than to authenticate them. External authentication systems may provide this information via request data such as
token which the pre-authentication system can extract. It is assumed that the external system is
responsible for the accuracy of the data and preventing the submission of forged values.
This filter will extract principal from the request only if url contains a "token" param.
If token exist then it will extract principal from the given token and build authentication object.
eg, http://host/projectName/services/pages/page?name="abc"invalid input: '&token'="YWRtaW46MTQ1NjEyMDMxMTY5ODpjOWUxZTRiYmFiYWQ0MTdhOGNiMWYyNTI1NmY2MTJlMg"
- Since:
- 8/2/16
-
Field Summary
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger -
Constructor Summary
ConstructorsConstructorDescriptionWMTokenBasedPreAuthenticatedProcessingFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager, WMTokenBasedAuthenticationService wmTokenBasedAuthenticationService) -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck whether all required properties have been set.voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) protected StringgetTokenFromReq(jakarta.servlet.http.HttpServletRequest request) voidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) voidsetAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager) voidsetAuthenticationSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler authenticationSuccessHandler) voidsetContinueFilterChainOnUnsuccessfulAuthentication(boolean continueFilterChainOnUnsuccessfulAuthentication) Deprecated.voidsetWmTokenBasedAuthenticationService(WMTokenBasedAuthenticationService wmTokenBasedAuthenticationService) protected voidsuccessfulAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authResult) Puts theAuthenticationinstance returned by the authentication manager into the secure context.protected voidunsuccessfulAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException failed) Ensures the authentication object in the secure context is set to null when authentication fails.Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
-
Constructor Details
-
WMTokenBasedPreAuthenticatedProcessingFilter
public WMTokenBasedPreAuthenticatedProcessingFilter() -
WMTokenBasedPreAuthenticatedProcessingFilter
public WMTokenBasedPreAuthenticatedProcessingFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager, WMTokenBasedAuthenticationService wmTokenBasedAuthenticationService)
-
-
Method Details
-
afterPropertiesSet
public void afterPropertiesSet()Check whether all required properties have been set.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Overrides:
afterPropertiesSetin classorg.springframework.web.filter.GenericFilterBean
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException
-
getTokenFromReq
-
successfulAuthentication
protected void successfulAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.Authentication authResult) Puts theAuthenticationinstance returned by the authentication manager into the secure context. -
unsuccessfulAuthentication
protected void unsuccessfulAuthentication(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, org.springframework.security.core.AuthenticationException failed) Ensures the authentication object in the secure context is set to null when authentication fails. Caches the failure exception as a request attribute -
setApplicationEventPublisher
public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) - Specified by:
setApplicationEventPublisherin interfaceorg.springframework.context.ApplicationEventPublisherAware
-
setAuthenticationManager
public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager) - Parameters:
authenticationManager- The AuthenticationManager to use
-
setContinueFilterChainOnUnsuccessfulAuthentication
@Deprecated public void setContinueFilterChainOnUnsuccessfulAuthentication(boolean continueFilterChainOnUnsuccessfulAuthentication) Deprecated.If set totrue, anyAuthenticationExceptionraised by theAuthenticationManagerwill be swallowed, and the request will be allowed to proceed, potentially using alternative authentication mechanisms. Iffalse(the default), authentication failure will result in an immediate exception.- Parameters:
continueFilterChainOnUnsuccessfulAuthentication- set totrueto allow the request to proceed after a failed authentication.
-
setWmTokenBasedAuthenticationService
public void setWmTokenBasedAuthenticationService(WMTokenBasedAuthenticationService wmTokenBasedAuthenticationService) -
setAuthenticationSuccessHandler
public void setAuthenticationSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler authenticationSuccessHandler)
-