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
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the CIDRUtils utility class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the Broadcast Address from the provided CIDR specification.
    Return the Network Address from the provided CIDR specification.
    boolean
    isInRange(String ipAddress)
    Return whether an IP Address is within the provided CIDR specification.
    Return a string representation of the CIDR specification consisting of the start and end addresses.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

  • Method Details

    • 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
    • toString

      public String toString()
      Return a string representation of the CIDR specification consisting of the start and end addresses.
      Overrides:
      toString in class Object
      Returns:
      the start and end addresses of the CIDR Specification.