use of mom.trd.opentheso.SelectedBeans.CurrentUser in project opentheso by miledrousset.
the class loginFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
CurrentUser session = (CurrentUser) req.getSession().getAttribute("user1");
String url = req.getRequestURI();
Connexion conn = (Connexion) request.getServletContext().getAttribute("poolConnexion");
HikariDataSource hds;
if (url.contains("install.xhtml") || url.contains("no_connection")) {
chain.doFilter(request, response);
return;
} else {
if (conn != null) {
hds = (HikariDataSource) conn.getPoolConnexion();
if (hds == null) {
resp.sendRedirect("./admin/no_connection.xhtml");
return;
}
}
if (conn == null) {
resp.sendRedirect("./admin/no_connection.xhtml");
return;
}
}
/* if(req.getRequestedSessionId()==null || !req.isRequestedSessionIdValid()){
req.getSession(true);
resp.sendRedirect("/index.xhtml");
}*/
if (session != null) {
// resp.sendRedirect("./install.xhtml");
if (session.getConnect().getPoolConnexion() == null) {
return;
}
}
if (url.contains("deco.xhtml")) {
CurrentUser temp = (CurrentUser) req.getSession().getAttribute("user1");
temp.setUser(new NodeUser());
temp.setIsLogged(false);
req.getSession().setAttribute("user1", temp);
((SelectedCandidat) req.getSession().getAttribute("selectedCandidat")).reInit();
// req.getServletContext().getContextPath());
resp.sendRedirect("./index.xhtml");
} else if (session == null || !session.isLogged()) {
if (url.contains("conf.xhtml") || url.contains("gestCandidat.xhtml") || url.contains("edition.xhtml") || url.contains("statistic.xhtml")) {
resp.sendRedirect(req.getServletContext().getContextPath());
} else {
chain.doFilter(request, response);
}
} else {
if (url.contains("connect.xhtml")) {
resp.sendRedirect(req.getServletContext().getContextPath());
} else {
chain.doFilter(request, response);
}
}
}
Aggregations