Package com.nelioalves.cursomc.security
Class JWTAuthenticationFilter
- java.lang.Object
-
- org.springframework.web.filter.GenericFilterBean
-
- org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
-
- org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
-
- com.nelioalves.cursomc.security.JWTAuthenticationFilter
-
- All Implemented Interfaces:
javax.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.context.MessageSourceAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public class JWTAuthenticationFilter extends org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilterClasse que representa filtro de autenticação- Author:
- José Henrique
-
-
Field Summary
-
Fields inherited from class org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
SPRING_SECURITY_FORM_PASSWORD_KEY, SPRING_SECURITY_FORM_USERNAME_KEY
-
-
Constructor Summary
Constructors Constructor Description JWTAuthenticationFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager, JWTUtil jwtUtil)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.security.core.AuthenticationattemptAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse)Tenta fazer a autenticação de usuárioprotected voidsuccessfulAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, javax.servlet.FilterChain filterChain, org.springframework.security.core.Authentication authentication)Retorna um token JWT para o usuário caso a autenticação tenha ocorrido com sucesso-
Methods inherited from class org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
getPasswordParameter, getUsernameParameter, obtainPassword, obtainUsername, setDetails, setPasswordParameter, setPostOnly, setUsernameParameter
-
Methods inherited from class org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter
afterPropertiesSet, doFilter, getAllowSessionCreation, getAuthenticationManager, getFailureHandler, getRememberMeServices, getSuccessHandler, requiresAuthentication, setAllowSessionCreation, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setContinueChainBeforeSuccessfulAuthentication, setFilterProcessesUrl, setMessageSource, setRememberMeServices, setRequiresAuthenticationRequestMatcher, setSessionAuthenticationStrategy, unsuccessfulAuthentication
-
-
-
-
Constructor Detail
-
JWTAuthenticationFilter
public JWTAuthenticationFilter(org.springframework.security.authentication.AuthenticationManager authenticationManager, JWTUtil jwtUtil)
-
-
Method Detail
-
attemptAuthentication
public org.springframework.security.core.Authentication attemptAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws org.springframework.security.core.AuthenticationExceptionTenta fazer a autenticação de usuário- Overrides:
attemptAuthenticationin classorg.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter- Parameters:
httpServletRequest- Requisição feita pelo usuáriohttpServletResponse- Resposta a ser enviada pelo usuário- Returns:
- Um Authentication
- Throws:
org.springframework.security.core.AuthenticationException
-
successfulAuthentication
protected void successfulAuthentication(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, javax.servlet.FilterChain filterChain, org.springframework.security.core.Authentication authentication) throws IOException, javax.servlet.ServletExceptionRetorna um token JWT para o usuário caso a autenticação tenha ocorrido com sucesso- Overrides:
successfulAuthenticationin classorg.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter- Parameters:
httpServletRequest- Requisição feita pelo usuáriohttpServletResponse- Resposta a ser enviada para o usuáriofilterChain- Objeto usado para chamada de funções posteriores na cadeia de responsabilidadeauthentication- Autenticação feita anteriormente em attemptAuthentication- Throws:
IOExceptionjavax.servlet.ServletException
-
-