Advertisement
Guest User

Untitled

a guest
May 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. public class FiltroLogin implements Filter {
  2.     public void init(final FilterConfig fConfig) throws ServletException {
  3.     }
  4.  
  5.     public void doFilter(final ServletRequest request,
  6.             final ServletResponse response, final FilterChain chain)
  7.             throws IOException, ServletException {
  8.         final HttpServletRequest req = (HttpServletRequest) request;
  9.         final HttpServletResponse resp = (HttpServletResponse) response;
  10.  
  11.         if (!req.getRequestURI().contains("/pfcJMG/index.jsf")) {
  12.             final ControladorUsuario controladorUsuario = (ControladorUsuario) req
  13.                     .getSession().getAttribute("usuarioLogueado");
  14.             if (controladorUsuario == null
  15.                     || controladorUsuario.getUsuario() == null) {
  16.                 resp.sendRedirect("/pfcJMG/index.jsf");
  17.                 return;
  18.             }
  19.         }
  20.         chain.doFilter(request, response);
  21.     }
  22.  
  23.     public void destroy() {
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement