AuthenticationException 3

14.DelegatingFilterProxy, FilterChainProxy

DelegatingFilterProxy Filter는 Servlet 2.3 이상부터 적용된 기술이다. Spring 에서 필터가 동작한다는 것은 SpringContext 안에 Filter들이 있다는 뜻이된다. 하지만 Filter 는 ServletContext에 존재해 영역이 다르다. 결국 Filter는 스프링 기술이나 Bean을 Injection 받을 수 없다. 이렇게 각자 영역이 다른 상태에서 Servlet Spec 에서 사용되는 Filter를 사용할 수 있게끔 하는 것이 DelegatingFilterProxy 이다. DelegatingFilterProxy 의 작동원리 SpringBean 이 Filter를 상속한다. 이는 Filter Type Bean을 의미한다. DelegatingFilterProxy ..

12.ExceptionTranslationFilter, RequestCacheAwareFilter

ExceptionTranslationFilter 크게 2가지의 Exception 을 처리한다. AuthenticationException : 인증 예외 AccessDeniedException : 인가 예외 AuthenticationException , AccessDeniedException은 누가 Throw 할까. FilterSecurityInterceptor 라는 필터이다. SpringSecurity의 보안필터 중 제일 마지막에 위치한다. FilterSecurityInterceptor 앞에 위치한 Filter 가 ExceptionTranslationFilter 이다. ExceptionTranslationFilter 는 Try-Catch 문으로 감싸서 FilterSecurityInterceptor 를 호..

4.UsernamePasswordAuthenticationFilter

UsernamePasswordAuthenticationFilter? 로그인 처리, 인증기능 해주는 Filter이다. 실질적으로 사용자가 로그인을 하게되면, 인증처리가 이루어지는데 이 요청을 담당하여 인증처리를 하는 Filter가 UsernamePasswordAuthenticationFilter 이다. 흐름과 역할은, 분기점, 결과처리! 내부적으로 각각의 인증처리 역할에 따라 여러개의 클래스를 활용하게된다. 사용자가 인증을 시도 UsernamePasswordAuthenticationFilter가 요청을 받는다. AntPathRequestMatcher("/login") 가 요청 url이 로그인 url과 매칭되는지 검사한다. 매칭이 되면 다음단계 , 불일치하면 다른 Filter가 Chain 일치하면 Usern..