在JAAS登录模块中获取HttpSession / Request [英] Get HttpSession/Request in a JAAS Login Module

查看:151
本文介绍了在JAAS登录模块中获取HttpSession / Request的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的登录模块中获取HttpSession或Request。
我已经尝试过JACC,但它没有用。

I'm trying to obtain the HttpSession or Request in my Login Module. I already tried JACC, but it didn't work.

我需要这个,因为我必须在登录窗口中放置验证码。也许一些JAAS忍者知道更好的方法。我正在使用 kaptcha 来做到这一点。

I need this because I have to put a captcha in a login window. Maybe some JAAS ninja knows a better way to do that. I'm using kaptcha to do that.

提前感谢。

推荐答案

我在JBoss AS上运行的应用程序中完全这样做。

I do exactly that in my applications running on JBoss AS.

以下是我在登录模块中访问HttpServletRequest所做的工作:

Here's what I do to access the HttpServletRequest from within the login module:

HttpServletRequest request = (HttpServletRequest) PolicyContext.getContext(HttpServletRequest.class.getName());

然后我得到会话,提取验证码并根据屏幕上的请求参数对其进行验证。在我对用户进行身份验证后,我从会话中删除了captcha参数。这对我来说很好。

Then I get the session, extract the captcha and validate it against the request parameter from the screen. After I authenticate the user, I remove the captcha parameter from the session. This works fine for me.

请注意,在用户已经过身份验证后,EJB调用也可以激活登录模块。在这种情况下,当然,验证码参数不会在会话中。所以你应该检查一下。

Note that the login module can also be activated by EJB calls after the user is already authenticated. In that case, the captcha parameter won't be in the session, of course. So you should check it.

这篇关于在JAAS登录模块中获取HttpSession / Request的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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