Posts

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 = 

Linux command line - Locate Vs find

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. In this post we discuss about locate and find commands and understand which one is more effective from one another. Also we discuss few important options available for locate command. It is important to note that both of these search commands works well but locate works in more convenient way as it uses more effective ways to quickly process search queries issued by the users. Locate Vs find locate  is one of the easiest and efficient way of finding the files in the file system. Though both  find  and  locate  will find out the files in the file system,  locate  works in more effective and fastest way in finding the file. locate command relies on mlocate database. It will look through that database which contains bits and parts of files and their corresponding

Apache Http Server Configuration using httpd.conf

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. In this post, we discuss about various options that are available in Apache Http server configuration file httpd.conf. ServerTokens ServerTokens Prod - Server sends (ex, ): Server: Apache ServerTokens Major - Server sends (ex, ): Server: Apache/2 ServerTokens Minor - Server sends (ex, ): Server: Apache/2.0 ServerTokens Min - Server sends (ex, ): Server: Apache/2.0.41 ServerTokens OS - Server sends (ex, ): Server: Apache/2.0.41 (Unix) ServerTokens Full (or not specified) - Server sends (ex, ): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.3 ServerRoot - Root directory of Apache http server PidFile - [Run time directory]/httpd.pid - The file in which the Server should record its Process identification number when it starts. Timeout - 60 - The number of

Working with Linux command line

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 explain different commands used in Linux environment. I use Cygwin to interact with Linux server remotly and access and process different files over there. Let's get started. ssh [remote_server_ip_address] - Connect to the remote server. scp -r  xxx.pl  user@127.0.0.0:/tmp - Connects to the remote server with specified IP address with user and copy the file xxx.pl to the folder tmp on remote server. scp -vp user@127.0.0.0:/var/logs/audit\* /cygdrive/c/logs/auditlogs - Connects to the remote linux server with specified IP address as user and copy all the files from the folder /var/logs/audit to the destination windows folder c/logs/auditlogs . As i was working with Cygwin to connect to remote linux server, the destination folder should be prece

Accessing HttpServletRequest in normal Java class

Accessing HttpServletRequest in normal Java class  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. Recently i came across the situation at work where i need to access HttpServletRequest in a normal Java class inorder to get Ip Address from the request. In my normal Java class i do not have direct access to the request and hence i used the below code to do that. But the normal Java class should be the part of HttpServlet request thread. It means that the normal Java class is being called from a HttpServlet request thread. ServletRequest servletRequest = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest(); if(servletRequest instanceOf HttpServletRequest) {    ipAddress =  ((HttpServletRequest)request).getHeader(" X-Forwarded-For "); } if(ipAddress == null)

Problems and Solutions regarding Fedora VM

Hi, This post addresses the problems developers face in Fedora VM in their daily work. How to configure proxies to get internet connection in Guest VM? - Login to Fedora VM. - Click on arrow symbol located next to Battery icon. It may differ according to the flavour of VM     that you use. - Choose Wired Connected -> Wired Settings - Go to Network proxy and click on Settings icon. - There you go!!! Choose option Manual and set Http and Https proxies. Now you could able to access the internet in Guest VM too. Please add your experiences too. It would be helpful for others. find . -name scooter\* - find a file in a directory from a command line sudo mount -t vboxsf projects /home/malathiboggavarapu/Shared - Mounts the folder projects to /home/malathiboggavarapu/Shared in Fedora cp [src][dest] - Copies the file from src to dest mv [src][dest] - Moves the file from src to dest history | grep mount - Find mount from history. If history contains some commands related