I do just that in my applications running on JBoss AS.
Here is what I do to access the HttpServletRequest from the login module:
HttpServletRequest request = (HttpServletRequest) PolicyContext.getContext(HttpServletRequest.class.getName());
Then I get the session, extract the captcha and check it for the request parameter from the screen. After authenticating the user, I remove the captcha parameter from the session. This works great for me.
Note that the registration module can also be activated by EJB calls after the user has already authenticated. In this case, the captcha parameter will not be in the session, of course. Therefore, you must verify this.
source share