I am working on an AuthenticationFilter to redirect the user when he's not logged in. I am using TomEE 7.0.0-M2, so with Java-EE7 support.
AuthenticationFilter
@WebFilter(urlPatterns = "/*", dispatcherTypes = {DispatcherType.FORWARD, DispatcherType.REQUEST})
public class AuthenticationFilter implements Filter {
@Inject
private LoginBean loginBean;
...
LoginBean
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import java.io.Serializable;
@Named
@SessionScoped
public class LoginBean implements Serializable {
The problem is that the injected LoginBean is not the instance from the login.xhtml. So i can not verify if the user is successfully logged in.
The LoginBean is not in the session attributes, but i found the right loginBean here, but i have no idea how i can access it. But it looks like that the bean is in CDI but how can i access it from the WebFilter?