在 JBoss AS 6 中监听登录事件 [英] Listening for login events in JBoss AS 6

查看:24
本文介绍了在 JBoss AS 6 中监听登录事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 JBoss AS6 中运行的应用程序.正在使用FORM"身份验证方法进行身份验证,并且用户正在正确登录.

I have an application running in JBoss AS6. Authentication is working using the "FORM" auth method, and the user is logging in correctly.

我希望能够在用户成功登录时调用一段自定义的静态代码.

I would like to be able to call a piece of custom, static code whenever a user successfully logs in.

不幸的是,我找不到任何侦听器、挂钩或回调,它们将在成功登录时执行代码.HttpSessionListener 确实有一个sessionCreated"事件,但是只要用户访问任何页面,即使他们没有成功登录,它也会被调用.这意味着即使查看登录表单也会触发活动.

Unfortunately, I cannot find any listener, or hook, or callback, which will execute code on successful login. The HttpSessionListener does have an event for "sessionCreated", but this is called as soon as a user accesses any page, even if they have not successfully logged in. That means that even viewing the login form triggers the event.

谁能给我指点一下 JBoss AS 6(或同等版本)的一些文档,其中展示了如何在用户首次成功登录时运行自定义代码?

Could anyone point me to some documentation for JBoss AS 6 (or equivalent) which shows how to run custom code at the point when a user first successfully logs in?

提前致谢.

推荐答案

可以在secure Servlet前面添加一个ServletFilter实现.

You can add a ServletFilter implementation in front of secured Servlet.

在每次调用时,过滤器将测试 HttpSession 中的布尔标志 notFirstCall.

At each invocation, the filter will test a boolean flag notFirstCall in HttpSession.

如果该标志不存在,则请求是用户登录后的第一个请求.它可以调用指定的作业,然后设置标志 notFirstCall 以将作业标记为此会话已完成.

If the flag is not present, the request is the first one after user's login. It can invoke the specified job and then set the flag notFirstCall to mark the job as done for this session.

这篇关于在 JBoss AS 6 中监听登录事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆