private boolean isAllowedAddress ( String ipAddress ) { if ( allowedAddresses == null ) { return false ; } // IPv4 int offset = ipAddress . lastIndexOf ( ' ' ) ; if ( offset == - 1 ) { // IPv6 offset = ipAddress . lastIndexOf ( ' ' ) ; if ( offset == - 1 ) { return false ; } } String ipAddressClass = ipAddress . substring ( 0 , offset + 1 ) + ' ' ; return ( allowedAddresses . contains ( ipAddressClass ) || allowedAddresses . contains ( ipAddress ) ) ; }
Returns whether IP address is valid .