Class CIDRMatch


  • public class CIDRMatch
    extends java.lang.Object
    Matches a request based on IP Address or subnet mask matching against the remote address.

    Both IPv6 and IPv4 addresses are supported, but a matcher which is configured with an IPv4 address will never match a request which returns an IPv6 address, and vice-versa.

    Since:
    3.0.2 Slightly modified by omidzk to have zero dependency to any frameworks other than the JRE. Slightly modified by rvowles to remove unnecessary code for our use case.
    Author:
    Luke Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      CIDRMatch()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean cidrMatch​(java.lang.String ipAddress, java.net.InetAddress remoteAddress)
      Takes a specific IP address or a range specified using the IP/Netmask (e.g.
      static java.net.InetAddress suppliedAddress​(java.lang.String address)  
      • Methods inherited from class java.lang.Object

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

      • CIDRMatch

        public CIDRMatch()
    • Method Detail

      • suppliedAddress

        public static java.net.InetAddress suppliedAddress​(java.lang.String address)
                                                    throws java.net.UnknownHostException
        Throws:
        java.net.UnknownHostException
      • cidrMatch

        public static boolean cidrMatch​(java.lang.String ipAddress,
                                        java.net.InetAddress remoteAddress)
        Takes a specific IP address or a range specified using the IP/Netmask (e.g. 192.168.1.0/24 or 202.24.0.0/14).
        Parameters:
        ipAddress - the address or range of addresses from which the request must come.