Class HiddenResourcesFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    public class HiddenResourcesFilter
    extends java.lang.Object
    implements javax.servlet.Filter
    Servlet filter blocking access to all configured resources. The purpose is to hide servlets which should be accessible only by internal forwards. To achieve this, this filter should be installed to protect them, with the request scope.
    Author:
    K. Benedyczak
    • Constructor Summary

      Constructors 
      Constructor Description
      HiddenResourcesFilter​(java.util.List<java.lang.String> protectedServletPaths)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addProtectedPath​(java.lang.String path)  
      void destroy()  
      void doFilter​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)  
      static boolean hasPathPrefix​(java.lang.String pathInfo, java.lang.String prefix)  
      static boolean hasPathPrefix​(java.lang.String pathInfo, java.util.List<java.lang.String> prefixes)  
      void init​(javax.servlet.FilterConfig filterConfig)  
      • Methods inherited from class java.lang.Object

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

      • HiddenResourcesFilter

        public HiddenResourcesFilter​(java.util.List<java.lang.String> protectedServletPaths)
    • Method Detail

      • doFilter

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

        public static boolean hasPathPrefix​(java.lang.String pathInfo,
                                            java.util.List<java.lang.String> prefixes)
      • hasPathPrefix

        public static boolean hasPathPrefix​(java.lang.String pathInfo,
                                            java.lang.String prefix)
      • destroy

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

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

        public void addProtectedPath​(java.lang.String path)