Class IPFilter

  • All Implemented Interfaces:
    jakarta.servlet.Filter

    public class IPFilter
    extends Object
    implements jakarta.servlet.Filter
    The filter which performs request's IP through allowance/restriction IP filtering rules that are loaded from the CMS (see CSM SiteConfig.FilteredIP). In case when an IP at the same time is allowed and restricted allowance has bigger priority. For restricted IPs is sent response with redirection on maintenance that configured via "maintenancePage" filter parameter in web.xml If "maintenancePage" parameter is not set then "403" response is returned. By default every application resource is in the restricted zone (zone for which IP filtering is performing) that can be changed by describing restricted resources by paths and/or by extensions. To describe restricted zone are used two initial filter parameters in web.xml:
    1. restrictedPaths with value as comma separated list of paths without leading slash symbol. E.g "cms,mui,admintools" restricts access to http://foo.bar/cms/index, http://foo.bar/mui/showAllProducers and so on
    2. restrictedExtensions with value as comma separated list of extensions without leading dot symbol. E.g. "html,action,js" restricts access to http://foo.bar/home.html, http://foo.bar/login.action and so on
    Everything else doesn't target to restricted zone.
    Author:
    dmetelin
    • Constructor Detail

      • IPFilter

        public IPFilter()
    • Method Detail

      • init

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

        public void destroy()
        Specified by:
        destroy in interface jakarta.servlet.Filter
      • doFilter

        public void doFilter​(jakarta.servlet.ServletRequest sreq,
                             jakarta.servlet.ServletResponse sres,
                             jakarta.servlet.FilterChain chain)
                      throws IOException,
                             jakarta.servlet.ServletException
        Specified by:
        doFilter in interface jakarta.servlet.Filter
        Throws:
        IOException
        jakarta.servlet.ServletException
      • getMaintenancePageURL

        protected String getMaintenancePageURL​(jakarta.servlet.http.HttpServletRequest req)
        Parameters:
        req - TODO dummy comment for javadoc.
        Returns:
        URL to maintenance page
      • isRestrictedZoneReq

        protected boolean isRestrictedZoneReq​(jakarta.servlet.http.HttpServletRequest req)
        Checks whether or not request came to restricted zone
        Parameters:
        req - request
        Returns:
        true if request to restricted zone