Package com.pingidentity.sdk
Class CIDRUtils
- java.lang.Object
-
- com.pingidentity.sdk.CIDRUtils
-
public class CIDRUtils extends Object
A utility class that provides address evaluation (network and broadcast) and in-range functionality for a given IP Address from a CIDR specification. This utility supports both IPv4 and IPv6 addresses.
IPv4 Example
10.77.12.11/18 would produce 10.77.0.0 for the networkAddress and 10.77.63.255 for the broadcastAddress.
IPv5 Example
435:23f::45:23/101 would produce 435:23f:0:0:0:0:0:0 for the networkAddress and 435:23f:0:0:0:0:7ff:ffff for the broadcastAddress.- Since:
- 8.1
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetBroadcastAddress()Return the Broadcast Address from the provided CIDR specification.StringgetNetworkAddress()Return the Network Address from the provided CIDR specification.booleanisInRange(String ipAddress)Return whether an IP Address is within the provided CIDR specification.StringtoString()Return a string representation of the CIDR specification consisting of the start and end addresses.
-
-
-
Constructor Detail
-
CIDRUtils
public CIDRUtils(String cidr) throws UnknownHostException
Constructor for the CIDRUtils utility class.- Parameters:
cidr- The CIDR specification to be evaluated.- Throws:
UnknownHostException
-
-
Method Detail
-
getNetworkAddress
public String getNetworkAddress()
Return the Network Address from the provided CIDR specification.- Returns:
- the Network Address.
-
getBroadcastAddress
public String getBroadcastAddress()
Return the Broadcast Address from the provided CIDR specification.- Returns:
- the Broadcast Address.
-
isInRange
public boolean isInRange(String ipAddress) throws UnknownHostException
Return whether an IP Address is within the provided CIDR specification.- Returns:
- true if the IP Address is in range of the CIDR specification.
- Throws:
UnknownHostException
-
-