Just do the same, s Filter. It's nice to know that the beans-managed JSF session is under covers that are stored as an attribute HttpSessionwith the managed name bean as the key.
Assuming you control a bean like this:
@ManagedBean
@SessionScoped
public class UserManager {
private User user;
public boolean isLoggedIn() {
return (user != null);
}
}
Then you can check it in Filter#doFilter()as follows:
UserManager userManager = (UserManager) ((HttpServletRequest) request).getSession().getAttribute("userManager");
if (userManager != null && userManager.isLoggedIn()) {
chain.doFilter(request, response);
} else {
((HttpServletResponse) response).sendRedirect("login.xhtml");
}
source
share