티스토리 뷰

Spring Security 4.2 에서 ConcurrentSessionFilter 사용 시 expiredUrl 사용이 Deprecated 되었습니다.


@Deprecated

public ConcurrentSessionFilter(SessionRegistry sessionRegistry, String expiredUrl) {

expiredUrl 대신 SessionInformationExpiredStrategy 를 사용하면 됩니다.


SessionInformationExpiredStrategy 생성자에 지정하지 않을 경우 Spring Security에 기본적으로 구현되어 있는


ResponseBodySessionInformationExpiredStrategy 가 적용 됩니다.



// 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();
}
}


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
TAG
more
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함