用户进入应用程序后立即显示弹出窗口

时间:2017-03-20 16:47:30

标签: java spring spring-mvc spring-security

我正在开发一个spring MVC应用程序我们正在使用Spring Security。

现在我要求一旦我进入应用程序,就会显示一个弹出窗口。因此,应用程序可以直接进入主页或其配置文件页面或应用程序中的任何其他流程。但是我需要显示弹出窗口而不管用户输入的位置。

如何使用Spring安全性或任何其他替代方法实现此目的?

我试过了: config.xml中:

<bean id="popUpFilter" class="myPackage.security.popUpClass" />
 <security:http entry-point-ref="myAppAuthEntryPoint" use-expressions="true">
.............
    <security:custom-filter after="LOGIN_FILTER" ref="popUpFilter"/>
</security:http>

和我的代码:

public class popUpClass implements AuthenticationSuccessHandler {

private static final Logger log = LoggerFactory.getLogger(popUpClass.class);

@Override
public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
    //do some logic here if you want something to be done whenever
    //the user successfully logs in.
    log.debug("Entered into customfilter");

    HttpSession session = httpServletRequest.getSession();
    User user =  SecurityClass.getUserDetails();
    session.setAttribute("id", user.ID());
    session.setAttribute("state", user.State());

    //set our response to OK status
    httpServletResponse.setStatus(HttpServletResponse.SC_OK);

    //since we have created our custom success handler, its up to us to where
    //we will redirect the user after successfully login
    httpServletResponse.sendRedirect("home");
}

}

注意:弹出窗口应该只在用户登录后出现一次。

0 个答案:

没有答案