Posts

Showing posts with the label Apache commons net 3.6 API

Filter proxy addresses using SubnetUtils (Apache Commons Net 3.6 API)

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. This post illustrate how to filter out internal proxy addresses from the real client IP address whereas internal proxy address is represented in the form of CIDR notation in your application Example of CIDR notation of IP addresses. 10.0.0.0/8 - This represents range of IP addresses from 10.0.0.0 to 10.255.255.255 Try it out at  https://mxtoolbox.com/subnetcalculator.aspx In below example we use SubnetUtils of Apache Common Net 3.6 API to check whether particular IP address is in range of IP addresses which is represented in CIDR notation. We also illsutrate how to use Java 8 stream, Map, Filter along with the Predicate which is passed to Filter. SubnetUtils have a method called isInRange to check whether the particular IP address is in range of IP addresses. Se