Class AuthGuardFilter

java.lang.Object
jakarta.servlet.GenericFilter
jakarta.servlet.http.HttpFilter
me.nickhanson.codeforge.web.AuthGuardFilter
All Implemented Interfaces:
jakarta.servlet.Filter, jakarta.servlet.FilterConfig, Serializable

@WebFilter(urlPatterns="/*") public class AuthGuardFilter extends jakarta.servlet.http.HttpFilter
AuthGuardFilter is a servlet filter that enforces authentication for specific routes. It intercepts HTTP requests and checks if the user is logged in before allowing access to protected resources. If the user is not authenticated, they are redirected to the login page.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doFilter(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, jakarta.servlet.FilterChain chain)
    Filters incoming HTTP requests to enforce authentication for protected routes.

    Methods inherited from class jakarta.servlet.http.HttpFilter

    doFilter

    Methods inherited from class jakarta.servlet.GenericFilter

    getFilterConfig, getFilterName, getInitParameter, getInitParameterNames, getServletContext, init, init

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface jakarta.servlet.Filter

    destroy
  • Constructor Details

    • AuthGuardFilter

      public AuthGuardFilter()
  • Method Details

    • doFilter

      protected void doFilter(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Filters incoming HTTP requests to enforce authentication for protected routes.
      Overrides:
      doFilter in class jakarta.servlet.http.HttpFilter
      Parameters:
      req - The HttpServletRequest object that contains the request the client made.
      resp - The HttpServletResponse object that contains the response the server sends.
      chain - The FilterChain object to pass the request and response to the next filter.
      Throws:
      IOException - If an input or output error occurs while processing the request.
      jakarta.servlet.ServletException - If the request cannot be handled.