|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.shibboleth.utilities.java.support.net.IPRange
public class IPRange
Represents a range of IP addresses.
| Field Summary | |
|---|---|
private int |
addressLength
Number of bits within the address. |
private BitSet |
host
The IP host address, if a host address rather than a network address was specified. |
private BitSet |
mask
The netmask for the range. |
private BitSet |
network
The IP network address for the range. |
| Constructor Summary | |
|---|---|
IPRange(byte[] address,
int maskSize)
Constructor. |
|
IPRange(InetAddress address,
int maskSize)
Constructor. |
|
| Method Summary | |
|---|---|
boolean |
contains(byte[] address)
Determines whether the given address is contained in the IP range. |
boolean |
contains(InetAddress address)
Determines whether the given address is contained in the IP range. |
InetAddress |
getHostAddress()
Returns the host address originally specified for this range, if it was a host address rather than a network address. |
InetAddress |
getNetworkAddress()
Returns the network address corresponding to this range as an InetAddress. |
static IPRange |
parseCIDRBlock(String cidrBlock)
Parses a CIDR block definition in to an IP range. |
protected BitSet |
toBitSet(byte[] bytes)
Converts a byte array to a BitSet. |
private byte[] |
toByteArray(BitSet bits)
Convert a BitSet representing an address into an
equivalent array of bytes, sized according to the address
length of this IPRange. |
private InetAddress |
toInetAddress(BitSet bits)
Convert a BitSet representing an address into an
equivalent InetAddress. |
private static void |
validateIPAddress(String address)
Validate an IP address for use as the base of a CIDR block. |
private static void |
validateV4Address(String address)
Validate an IPv4 address for use as the base of a CIDR block. |
private static void |
validateV6Address(String address)
Validate an IPv6 address for use as the base of a CIDR block. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final int addressLength
private final BitSet network
private final BitSet host
private BitSet mask
| Constructor Detail |
|---|
public IPRange(InetAddress address,
int maskSize)
address - address to base the range on; may be the network address or the
address of a host within the networkmaskSize - the number of bits in the netmask
public IPRange(byte[] address,
int maskSize)
address - address to base the range on; may be the network address or the
address of a host within the networkmaskSize - the number of bits in the netmask| Method Detail |
|---|
public InetAddress getNetworkAddress()
InetAddress.
InetAddresspublic InetAddress getHostAddress()
InetAddress, or nullprivate static void validateV4Address(String address)
address - the address to validateprivate static void validateV6Address(String address)
InetAddress parser.
Throws IllegalArgumentException if validation fails.
address - the address to validateprivate static void validateIPAddress(String address)
address - the address to validatepublic static IPRange parseCIDRBlock(String cidrBlock)
cidrBlock - the CIDR block definition
public boolean contains(InetAddress address)
address - the address to check
public boolean contains(byte[] address)
address - the address to check
protected BitSet toBitSet(byte[] bytes)
bytes - the byte array with most significant bit in element 0.
private byte[] toByteArray(BitSet bits)
BitSet representing an address into an
equivalent array of bytes, sized according to the address
length of this IPRange.
bits - BitSet representing an address
private InetAddress toInetAddress(BitSet bits)
BitSet representing an address into an
equivalent InetAddress.
Returns null for either a null BitSet or for any
problems encountered by InetAddress.
bits - BitSet representing an address
InetAddress representing the same address
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||