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

查看:123
本文介绍了在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?

提前致谢。

推荐答案

您可以添加 ServletFilter 在安全Servlet前实现。

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

在每次调用时,过滤器将测试一个布尔标志 notFirstCall in HttpSession

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天全站免登陆