Class IPAddressParser

java.lang.Object
org.apache.kerby.util.IPAddressParser

public class IPAddressParser extends Object
Parses String representations of IPv4 and IPv6 addresses, and converts them to byte[]. Returns null if the supplied String is not a valid IP address. IPv6 addresses are allowed to include square brackets (e.g., "[::a:b:c:d]"), but IPv4 addresses are not. This is to help in situation where an IPv6 literal address is encoded directly inside a URL (the square brackets allow the web client to separate the IPv6 address from its port, since the colon character is overloaded in that context).
  • Constructor Details

    • IPAddressParser

      public IPAddressParser()
  • Method Details

    • parseIPv4Literal

      public static byte[] parseIPv4Literal(String s)
      Converts the supplied IPv4 literal to byte[], or null if the IPv4 address was invalid.
      Parameters:
      s - Literal IPv4 address.
      Returns:
      byte[] array or null if the supplied IPv4 address was invalid.
    • parseIPv6Literal

      public static byte[] parseIPv6Literal(String s)
      Converts the supplied IPv6 literal to byte[], or null if the IPv6 address was invalid.
      Parameters:
      s - Literal IPv6 address.
      Returns:
      byte[] array or null if the supplied IPv6 address was invalid.