-
1. Re: Not a valid response [302 Moved Temporarily]
ssilvert Aug 22, 2010 12:14 PM (in response to panayk)This page shows how to set the WebClient redirectEnabled flag:
http://community.jboss.org/wiki/JSFSessionAPI
However, I'm pretty sure that following redirects is enabled by default.
Stan
-
2. Re: Not a valid response [302 Moved Temporarily]
panayk Aug 22, 2010 2:17 PM (in response to ssilvert)Hi! Many thanks. Perhaps I should start a new thread.
This is my situation.
I am using a servlet filter that uses the FacesContext. This is possible using the methods described (for example) here.
Here is some code:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
FacesContextBuilder builder = new FacesContextBuilder();FacesContext facesContext = builder.getFacesContext(request, response);
Application application = facesContext.getApplication();
ELContext elContext = facesContext.getELContext();
SessionController sessionController = (SessionController) application.getELResolver().getValue(elContext, null, "sessionController");User currentUser = sessionController.getCurrentUser();
if (currentUser == null)
{Based on the value of currentUser I either call chain.doFilter(request, response) or send a redirect.
It seems that as soon as the JSFSession is created doFilter is called. So it's too late to enable redirects.
A solution that comes to mind is setting currentUser before JSFSession is created. To do this I would need to access the JSFUnit FacesContext before creating the JSFSession. Is this possible?
Again, thank you.
Regards,
Panayiotis
-
3. Re: Not a valid response [302 Moved Temporarily]
ssilvert Aug 22, 2010 7:25 PM (in response to panayk)I don't know enough about your applicaiton to give a good answer.
What is the SessionController? Where is it getting the current user from?
I don't see why you need a FacesContext to get the current user. Isn't there another way?
If you are using standard JEE authentication then you can get the remote user from the HttpServletRequest.
Stan