Class InetAccessHandler

  • All Implemented Interfaces:
    Handler, HandlerContainer, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.LifeCycle

    public class InetAccessHandler
    extends HandlerWrapper
    InetAddress Access Handler

    Controls access to the wrapped handler using the real remote IP. Control is provided by and IncludeExcludeSet over a InetAddressSet. This handler uses the real internet address of the connection, not one reported in the forwarded for headers, as this cannot be as easily forged.

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

        org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
      • Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

        org.eclipse.jetty.util.component.LifeCycle.Listener
    • Field Summary

      • Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
      • Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

        KEY
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dump​(java.lang.Appendable out, java.lang.String indent)  
      void exclude​(java.lang.String pattern)
      Excludes an InetAddress pattern
      void exclude​(java.lang.String... patterns)
      Excludes InetAddress patterns
      void handle​(java.lang.String target, Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Checks the incoming request against the whitelist and blacklist
      void include​(java.lang.String pattern)
      Includes an InetAddress pattern
      void include​(java.lang.String... patterns)
      Includes InetAddress patterns
      protected boolean isAllowed​(java.net.InetAddress address, javax.servlet.http.HttpServletRequest request)
      Checks if specified address and request are allowed by current InetAddress rules.
      • Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle

        addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
      • Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

        addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

        dumpSelf
      • Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle

        addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
    • Constructor Detail

      • InetAccessHandler

        public InetAccessHandler()
    • Method Detail

      • include

        public void include​(java.lang.String pattern)
        Includes an InetAddress pattern
        Parameters:
        pattern - InetAddress pattern to include
        See Also:
        InetAddressSet
      • include

        public void include​(java.lang.String... patterns)
        Includes InetAddress patterns
        Parameters:
        patterns - InetAddress patterns to include
        See Also:
        InetAddressSet
      • exclude

        public void exclude​(java.lang.String pattern)
        Excludes an InetAddress pattern
        Parameters:
        pattern - InetAddress pattern to exclude
        See Also:
        InetAddressSet
      • exclude

        public void exclude​(java.lang.String... patterns)
        Excludes InetAddress patterns
        Parameters:
        patterns - InetAddress patterns to exclude
        See Also:
        InetAddressSet
      • handle

        public void handle​(java.lang.String target,
                           Request baseRequest,
                           javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws java.io.IOException,
                           javax.servlet.ServletException
        Checks the incoming request against the whitelist and blacklist
        Specified by:
        handle in interface Handler
        Overrides:
        handle in class HandlerWrapper
        Parameters:
        target - The target of the request - either a URI or a name.
        baseRequest - The original unwrapped request object.
        request - The request either as the Request object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getRequest() method can be used access the Request object if required.
        response - The response as the Response object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getResponse() method can be used access the Response object if required.
        Throws:
        java.io.IOException - if unable to handle the request or response processing
        javax.servlet.ServletException - if unable to handle the request or response due to underlying servlet issue
      • isAllowed

        protected boolean isAllowed​(java.net.InetAddress address,
                                    javax.servlet.http.HttpServletRequest request)
        Checks if specified address and request are allowed by current InetAddress rules.
        Parameters:
        address - the inetAddress to check
        request - the request to check
        Returns:
        true if inetAddress and request are allowed
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
        Overrides:
        dump in class org.eclipse.jetty.util.component.ContainerLifeCycle
        Throws:
        java.io.IOException