Class IpMatcher

java.lang.Object
org.exoplatform.addons.saml.extensions.IpMatcher

public class IpMatcher extends Object
Matches a client IP address against a list of IPv4/IPv6 addresses, CIDR blocks and ranges. Entries are separated by comma, semicolon or whitespace:
  • 10.1.2.3: a single address
  • 10.0.0.0/8 or 2001:db8::/32: a CIDR block
  • 192.168.1.10-192.168.1.50: an inclusive range
Spaces around the - and the / are accepted. Only literal addresses are accepted, host names are never resolved. An invalid entry is ignored and reported at error level: it enforces nothing.
  • Constructor Details

    • IpMatcher

      public IpMatcher(String entries)
  • Method Details

    • isEmpty

      public boolean isEmpty()
    • getEntries

      public List<String> getEntries()
      Returns:
      the entries that are in effect, for the logs
    • matches

      public boolean matches(String address)
      Parameters:
      address - the remote address of a request
      Returns:
      true when the address is in one of the configured entries
    • isClientAddress

      public static boolean isClientAddress(String address)
      Parameters:
      address - the remote address of a request
      Returns:
      true when the address is an IPv4 or IPv6 literal, once a port, the brackets of an IPv6 address or a zone are removed. A reverse proxy may put them in the X-Forwarded-For value that Tomcat copies