스프링 3.1을 사용하는 자바 웹 애플리케이션이 있습니다. My Spring 보안 컨텍스트는 각각 다른 인증 경로 (예 : 사용자 이름/비밀번호 대 Single Sign On)에 해당하는 여러 인증 필터를 정의합니다. 각 인증 필터는 자체적으로 AuthenticationSuccessHandler
을 정의합니다. 이제 모든 인증 유형을 나는 성공적인 인증에 걸릴이 추가 작업을 주입 할, 그들은 에 적용해야합니다여러 AuthenticationSuccessHandlers를 가장 깨끗하게 호출하는 방법은 무엇입니까?
- 설정 Google 웹 로그 분석 프런트 엔드에 사용하기위한 추적 이벤트 코드
- 데이터베이스에서 사용자의 기본 설정 로케일을 업데이트하십시오.
사용자가 성공적으로 인증 된 후 수행 할 수있는 작업입니다. 중요한 포인트는 (각 인증 경로마다 다른) 정규 AuthenticationSuccessHandlers와 달리 요청을 전달하거나 리디렉션하지 않는다는 것입니다. 그래서 그들에게 전화하는 것이 안전합니다.
Spring Web/Security 3.1을 사용하여 이러한 추가 인증 성공 "액션"을 통합하는 명확한 방법이 있습니까?
ApplicationListener<AuthenticationSuccessEvent>
을 구현했지만 내 이벤트는 요청에 액세스해야하며 AuthenticationSuccessEvent
은 모두 Authentication
개체를 제공합니다.
나는 방법을 찾을 수 없습니다, 그래서 난 내 자신의 프록시 출시하기로 결정 AuthenticationSuccessHandler.onAuthenticationSuccess(...)
는 내가 어떤 표시되지 않습니다라고 AbstractAuthenticationProcessingFilter
의 소스 코드와 모든 다른 장소에 breafly보고 후
public class AuthenticationSuccessHandlerProxy implements AuthenticationSuccessHandler {
private List<AuthenticationSuccessHandler> authenticationSuccessHandlers;
public AuthenticationSuccessHandlerProxy(List<AuthenticationSuccessHandler> successHandlers) {
this.authenticationSuccessHandlers = successHandlers;
}
@Override
public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response,
Authentication authentication) throws IOException, ServletException {
for (AuthenticationSuccessHandler successHandler : this.authenticationSuccessHandlers) {
successHandler.onAuthenticationSuccess(request, response, authentication);
}
}
}