edu.internet2.middleware.shibboleth.idp.util
Class IPRange

java.lang.Object
  extended by edu.internet2.middleware.shibboleth.idp.util.IPRange

public class IPRange
extends Object

Represents a range of IP addresses.


Field Summary
private  int addressLength
          Number of bits within
private  BitSet mask
          The netmask for the range.
private  BitSet network
          The IP network address for the range.
 
Constructor Summary
IPRange(byte[] networkAddress, int maskSize)
          Constructor
IPRange(InetAddress networkAddress, 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.
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addressLength

private int addressLength
Number of bits within


network

private BitSet network
The IP network address for the range.


mask

private BitSet mask
The netmask for the range.

Constructor Detail

IPRange

public IPRange(InetAddress networkAddress,
               int maskSize)
Constructor

Parameters:
networkAddress - the network address for the range
maskSize - the number of bits in the netmask

IPRange

public IPRange(byte[] networkAddress,
               int maskSize)
Constructor

Parameters:
networkAddress - the network address for the range
maskSize - the number of bits in the netmask
Method Detail

parseCIDRBlock

public static IPRange parseCIDRBlock(String cidrBlock)
Parses a CIDR block definition in to an IP range.

Parameters:
cidrBlock - the CIDR block definition
Returns:
the resultant IP range

contains

public boolean contains(InetAddress address)
Determines whether the given address is contained in the IP range.

Parameters:
address - the address to check
Returns:
true if the address is in the range, false it not

contains

public boolean contains(byte[] address)
Determines whether the given address is contained in the IP range.

Parameters:
address - the address to check
Returns:
true if the address is in the range, false it not

toBitSet

protected BitSet toBitSet(byte[] bytes)
Converts a byte array to a BitSet. The supplied byte array is assumed to have the most significant bit in element 0.

Parameters:
bytes - the byte array with most significant bit in element 0.
Returns:
the BitSet


Copyright © 1999-2012. All Rights Reserved.