public static boolean isIpAddressAllowed(String ipAddress, String... whitelist) {

		if (StringUtils.isNullOrEmpty(ipAddress) || whitelist == null || whitelist.length == 0) {
			return false;
		}

		for (String address : whitelist) {

			if (ipAddress.equals(address)) {
				return true;
			}

			if (address.contains("/")) { // is range definition

				SubnetUtils utils = new SubnetUtils(address);
				utils.setInclusiveHostCount(true);

				if (utils.getInfo().isInRange(ipAddress)) {
					return true;
				}
			}
		}

		return false;
	}
public static boolean isIpAddressAllowed ( String ipAddress , String ... whitelist ) { if ( StringUtils . isNullOrEmpty ( ipAddress ) || whitelist == null || whitelist . length == 0 ) { return false ; } for ( String address : whitelist ) { if ( ipAddress . equals ( address ) ) { return true ; } if ( address . contains ( "/" ) ) { SubnetUtils utils = new SubnetUtils ( address ) ; utils . setInclusiveHostCount ( true ) ; if ( utils . getInfo ( ) . isInRange ( ipAddress ) ) { return true ; } } } return false ; }
Compares ipAddress with one of the ip addresses listed

@param ipAddress ip address to compare
@param whitelist list of ip addresses ... an be a range ip ... in format 123.123.123.123/28 where last part is a subnet range
@return true if allowed, false if not