Class InetAccessHandler

All Implemented Interfaces:
Handler, Handler.Container, Handler.Singleton, Request.Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable

public class InetAccessHandler extends ConditionalHandler.Abstract
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.

  • Constructor Details

    • InetAccessHandler

      public InetAccessHandler()
    • InetAccessHandler

      public InetAccessHandler(Handler handler)
  • Method Details

    • onConditionsMet

      protected boolean onConditionsMet(Request request, Response response, Callback callback) throws Exception
      Description copied from class: ConditionalHandler
      Handle a request that has met the conditions. Typically, the implementation will provide optional handling and then call the ConditionalHandler.nextHandler(Request, Response, Callback) method to continue handling.
      Specified by:
      onConditionsMet in class ConditionalHandler
      Parameters:
      request - The request to handle
      response - The response to generate
      callback - The callback for completion
      Returns:
      True if this handler will complete the callback
      Throws:
      Exception - If there is a problem handling
      See Also:
    • onConditionsNotMet

      protected boolean onConditionsNotMet(Request request, Response response, Callback callback) throws Exception
      Description copied from class: ConditionalHandler
      This method is called when the request has not met the conditions and is not to be handled by this handler. Implementations may return false; send an error response; or handle the request differently.
      Specified by:
      onConditionsNotMet in class ConditionalHandler
      Parameters:
      request - The request to handle
      response - The response to generate
      callback - The callback for completion
      Returns:
      True if this handler will complete the callback
      Throws:
      Exception - If there is a problem handling
      See Also:
    • include

      public void include(String pattern)
      Includes an InetAccess pattern with an optional connector name, address and URI mapping.

      The connector name is separated from the InetAddress pattern with an '@' character, and the InetAddress pattern is separated from the URI pattern using the "|" (pipe) character. URI patterns follow the servlet specification for simple * prefix and suffix wild cards (e.g. /, /foo, /foo/bar, /foo/bar/*, *.baz).


      Examples:
      • "connector1@127.0.0.1|/foo"
      • "127.0.0.1|/foo"
      • "connector1@127.0.0.1"
      • "127.0.0.1"
      Parameters:
      pattern - InetAccess pattern to include
      See Also:
    • include

      public void include(String... patterns)
      Includes InetAccess patterns
      Parameters:
      patterns - InetAddress patterns to include
      See Also:
    • include

      public void include(String connectorName, String addressPattern, PathSpec pathSpec)
      Includes an InetAccess entry.
      Parameters:
      connectorName - optional name of a connector to include.
      addressPattern - optional InetAddress pattern to include.
      pathSpec - optional pathSpec to include.
    • exclude

      public void exclude(String pattern)
      Excludes an InetAccess entry pattern with an optional connector name, address and URI mapping.

      The connector name is separated from the InetAddress pattern with an '@' character, and the InetAddress pattern is separated from the URI pattern using the "|" (pipe) character. A method name is separated from the URI pattern using the ">" character. URI patterns follow the servlet specification for simple * prefix and suffix wild cards (e.g. /, /foo, /foo/bar, /foo/bar/*, *.baz).


      Examples:
      • "connector1@127.0.0.1|/foo"
      • "127.0.0.1|/foo"
      • "127.0.0.1>GET|/foo"
      • "127.0.0.1>GET"
      • "connector1@127.0.0.1"
      • "127.0.0.1"
      Parameters:
      pattern - InetAddress pattern to exclude
      See Also:
    • exclude

      public void exclude(String... patterns)
      Excludes InetAccess patterns
      Parameters:
      patterns - InetAddress patterns to exclude
      See Also:
    • exclude

      public void exclude(String connectorName, String addressPattern, PathSpec pathSpec)
      Excludes an InetAccess entry.
      Parameters:
      connectorName - optional name of a connector to exclude.
      addressPattern - optional InetAddress pattern to exclude.
      pathSpec - optional pathSpec to exclude.