Given a CIDR address, e.g. 192.168.10.0/24
192.168.10.0/24
24
255.255.
You can use org.springframework.security.web.util.IpAddressMatcher from Spring Framework.
org.springframework.security.web.util.IpAddressMatcher