티스토리 뷰
Spring Security 4.2 에서 ConcurrentSessionFilter 사용 시 expiredUrl 사용이 Deprecated 되었습니다.
@Deprecated
public ConcurrentSessionFilter(SessionRegistry sessionRegistry, String expiredUrl) {
expiredUrl 대신 SessionInformationExpiredStrategy 를 사용하면 됩니다.
SessionInformationExpiredStrategy 생성자에 지정하지 않을 경우 Spring Security에 기본적으로 구현되어 있는
ResponseBodySessionInformationExpiredStrategy 가 적용 됩니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spring Security에 적용되어 있는 ResponseBodySessionInformationExpiredStrategy | |
private static final class ResponseBodySessionInformationExpiredStrategy | |
implements SessionInformationExpiredStrategy { | |
@Override | |
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) | |
throws IOException, ServletException { | |
HttpServletResponse response = event.getResponse(); | |
response.getWriter().print( | |
"This session has been expired (possibly due to multiple concurrent " | |
+ "logins being attempted as the same user)."); | |
response.flushBuffer(); | |
} | |
} | |
// CustomSessionInformationExpiredStrategy | |
public class CustomSessionInformationExpiredStrategy implements SessionInformationExpiredStrategy { | |
@Override | |
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException { | |
HttpServletResponse response = event.getResponse(); | |
response.setCharacterEncoding("UTF-8"); | |
response.getWriter().print("<script type='text/javascript'>alert('동일 계정이 다른 곳에서 로그인 되었습니다. 자동 로그아웃 됩니다.');top.location.href = '/logoutProcess.do';</script>"); | |
response.flushBuffer(); | |
} | |
} |
'IT > Spring' 카테고리의 다른 글
logback 설정 예 (0) | 2017.02.01 |
---|---|
Quartz Schedule 사용 시 parameter 전달 xml에 설정하는 방법 (0) | 2016.11.30 |
Spring Security 4.2 Released (0) | 2016.11.15 |
WebSquare + Spring MVC Test Code (0) | 2016.10.05 |
annotation-driven 설정 없이 @ControllerAdvice 사용 설정 (0) | 2016.08.24 |