Posts

Showing posts from November, 2018

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

Java 8 Hands-on

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 is all about different usecases which use Java 8 features which could be helpful for anyone.Please post your comments below or if you need to address any legacy code using Java 8 features. Java 8 practical examples Scenario 1 The following code excerpt explains the following scenario and also demonstrates the usage of Java 8 Stream, Filter and map. - Split the IP Address with respect to a delimeter (,) and store it into a Collection.  - Filter out proxy addresses from the resulting Collection. - Join the result with delimeter (,). public static String filteredIpAddresses(){  String proxyAddresses = "10.12.12.13, 10.12.12.14";  String ipAdress = "46.150.151.10, 46.150.151.11";  Set<String> ipAdresses =