Package me.nickhanson.codeforge.web
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoFilter(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
doFilterMethods inherited from class jakarta.servlet.GenericFilter
getFilterConfig, getFilterName, getInitParameter, getInitParameterNames, getServletContext, init, initMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
doFilterin classjakarta.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.
-