org.springframework.security.web.session.SessionInformationExpiredEvent Java Examples

The following examples show how to use org.springframework.security.web.session.SessionInformationExpiredEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomExpiredSessionStrategy.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
/**
 * 根据需要返回 Url 或者 Json
 * @author jitwxs
 * @since 2018/11/29 18:46
 */
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    Map<String, Object> map = new HashMap<>(16);
    map.put("code", 0);
    map.put("msg", "已经另一台机器登录,您被迫下线。" + event.getSessionInformation().getLastRequest());
    // Map -> Json
    String json = objectMapper.writeValueAsString(map);

    event.getResponse().setContentType("application/json;charset=UTF-8");
    event.getResponse().getWriter().write(json);

    // 如果是跳转html页面,url代表跳转的地址
    // redirectStrategy.sendRedirect(event.getRequest(), event.getResponse(), "url");
}
 
Example #2
Source File: CustomExpiredSessionStrategy.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
/**
 * 根据需要返回 Url 或者 Json
 * @author jitwxs
 * @since 2018/11/29 18:46
 */
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    Map<String, Object> map = new HashMap<>(16);
    map.put("code", 0);
    map.put("msg", "已经另一台机器登录,您被迫下线。" + event.getSessionInformation().getLastRequest());
    // Map -> Json
    String json = objectMapper.writeValueAsString(map);

    event.getResponse().setContentType("application/json;charset=UTF-8");
    event.getResponse().getWriter().write(json);

    // 如果是跳转html页面,url代表跳转的地址
    // redirectStrategy.sendRedirect(event.getRequest(), event.getResponse(), "url");
}
 
Example #3
Source File: CustomExpiredSessionStrategy.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
/**
 * 根据需要返回 Url 或者 Json
 * @author jitwxs
 * @since 2018/11/29 18:46
 */
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    Map<String, Object> map = new HashMap<>(16);
    map.put("code", 0);
    map.put("msg", "已经另一台机器登录,您被迫下线。" + event.getSessionInformation().getLastRequest());
    // Map -> Json
    String json = objectMapper.writeValueAsString(map);

    event.getResponse().setContentType("application/json;charset=UTF-8");
    event.getResponse().getWriter().write(json);

    // 如果是跳转html页面,url代表跳转的地址
    // redirectStrategy.sendRedirect(event.getRequest(), event.getResponse(), "url");
}
 
Example #4
Source File: DefaultExpiredSessionStrategy.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    ResultMap resultMap = new ResultMap(getClass().getName() + ":onExpiredSessionDetected()",
            "您的 Session 已过期,请重新登录。" + event.getSessionInformation().getLastRequest());
    String json = objectMapper.writeValueAsString(resultMap);

    event.getResponse().setContentType("application/json;charset=UTF-8");
    event.getResponse().getWriter().write(json);
}
 
Example #5
Source File: DefaultExpiredSessionStrategy.java    From blog-sample with Apache License 2.0 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    ResultMap resultMap = new ResultMap(getClass().getName() + ":onExpiredSessionDetected()",
            "您的 Session 已过期,请重新登录。" + event.getSessionInformation().getLastRequest());
    String json = objectMapper.writeValueAsString(resultMap);

    event.getResponse().setContentType("application/json;charset=UTF-8");
    event.getResponse().getWriter().write(json);
}
 
Example #6
Source File: SingleLoginSessionInformationExpiredStrategy.java    From oauth-server with Apache License 2.0 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event)
        throws IOException, ServletException {
    HttpServletResponse response = event.getResponse();
    response.setHeader("Content-type", "text/html;charset=UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.getWriter().print("您的账号已在别处登录!要想继续访问,请刷新页面重新登录");
    response.flushBuffer();
}
 
Example #7
Source File: MySessionExpiredStrategy.java    From SpringAll with MIT License 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    HttpServletResponse response = event.getResponse();
    response.setStatus(HttpStatus.UNAUTHORIZED.value());
    response.setContentType("application/json;charset=utf-8");
    response.getWriter().write("您的账号已经在别的地方登录,当前登录已失效。如果密码遭到泄露,请立即修改密码!");
}
 
Example #8
Source File: MySessionExpiredStrategy.java    From SpringAll with MIT License 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    HttpServletResponse response = event.getResponse();
    response.setStatus(HttpStatus.UNAUTHORIZED.value());
    response.setContentType("application/json;charset=utf-8");
    response.getWriter().write("您的账号已经在别的地方登录,当前登录已失效。如果密码遭到泄露,请立即修改密码!");
}
 
Example #9
Source File: MySessionExpiredStrategy.java    From SpringAll with MIT License 5 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
    HttpServletResponse response = event.getResponse();
    response.setStatus(HttpStatus.UNAUTHORIZED.value());
    response.setContentType("application/json;charset=utf-8");
    response.getWriter().write("您的账号已经在别的地方登录,当前登录已失效。如果密码遭到泄露,请立即修改密码!");
}
 
Example #10
Source File: FebsExpiredSessionStrategy.java    From FEBS-Security with Apache License 2.0 4 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException {
    event.getResponse().setContentType(FebsConstant.JSON_UTF8);
    event.getResponse().getWriter().write(mapper.writeValueAsString(ResponseBo.unAuthorized("登录已失效")));
}
 
Example #11
Source File: NotAuthorizedSessionInformationExpiredStrategy.java    From govpay with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
	HttpServletResponse response = event.getResponse();
	Response payload = CodiceEccezione.AUTENTICAZIONE.toFaultResponse("Sessione Scaduta");
	AbstractBasicAuthenticationEntryPoint.fillResponse(response, payload, this.timeZone);
}
 
Example #12
Source File: NotAuthorizedSessionInformationExpiredStrategy.java    From govpay with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
	HttpServletResponse response = event.getResponse();
	Response payload = FaultCode.AUTORIZZAZIONE.toFaultResponse("Sessione Scaduta");
	AbstractBasicAuthenticationEntryPoint.fillResponse(response, payload, this.timeZone);
}