Class AuthFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class AuthFilter
    extends java.lang.Object
    implements javax.servlet.Filter
    Servlet filter that applies a predicate to incoming requests and rejects with with 403 "Forbidden" if the predicate returns false, otherwise it passes the request down the filter chain.

    Either the user from getRemoteUser is null, no authentication, or it has been validated. Failed authentication attempts will have been handled and rejected by the servlet container before they get to the filter chain.

    • Constructor Summary

      Constructors 
      Constructor Description
      AuthFilter​(java.util.function.Predicate<java.lang.String> allowAccess)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()  
      void doFilter​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filter)  
      void init​(javax.servlet.FilterConfig filterConfig)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AuthFilter

        public AuthFilter​(java.util.function.Predicate<java.lang.String> allowAccess)
    • Method Detail

      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain filter)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        java.io.IOException
        javax.servlet.ServletException
      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter