Package org.apache.kerby.util
Class IPAddressParser
java.lang.Object
org.apache.kerby.util.IPAddressParser
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Converts the supplied IPv4 literal to byte[], or null if the IPv4 address was invalid.static byte[]Converts the supplied IPv6 literal to byte[], or null if the IPv6 address was invalid.
-
Constructor Details
-
IPAddressParser
public IPAddressParser()
-
-
Method Details
-
parseIPv4Literal
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
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.
-