|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glite.security.util.IPAddressComparator
public class IPAddressComparator
An utility class used to compare ip addresses and to check whether an IP address is within a address space defined by IP address - netmask combination.
| Constructor Summary | |
|---|---|
IPAddressComparator()
|
|
| Method Summary | |
|---|---|
static byte[] |
andBytes(byte[] ip,
byte[] netmask)
This method does bitwise and between the two byte arrays. |
static boolean |
compare(byte[] item1,
byte[] item2)
Compares two byte arrays. |
static byte[][] |
concatArrayArrays(byte[][] first,
byte[][] second)
Concatenates two arrays of arrays bytes. |
static byte[] |
copyBytes(byte[] array,
int start,
int end)
Copies the items from the array to a new array starting from index start and ending at end - 1. |
static boolean |
isWithinAddressSpace(byte[] ipAddress,
byte[] ipAddressWithNetmask)
Tests whether the ipAddress is within the address space defined by the ipAddressWithNetmask. |
static byte[] |
parseIP(java.lang.String ip)
Parses the string representation of the IP address and returns the address as a byte array. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IPAddressComparator()
| Method Detail |
|---|
public static byte[] parseIP(java.lang.String ip)
ip - The IP address with optional netmask.
public static boolean compare(byte[] item1,
byte[] item2)
item1 - The first array to use for comparison.item2 - The second array to use for comparison.
public static boolean isWithinAddressSpace(byte[] ipAddress,
byte[] ipAddressWithNetmask)
ipAddress - The IP address bytes to compare against the address space.ipAddressWithNetmask - The 8 (IPv4) or 32 (IPv6) byte array containing in the first half the base IP address
bytes and in the second half the netmask bytes.
public static byte[] andBytes(byte[] ip,
byte[] netmask)
ip - The first array to use for the and operation.netmask - The second array to use for the and operation.
public static byte[] copyBytes(byte[] array,
int start,
int end)
array - The array holding the bytes to copy.start - The index where to start copying, inclusive.end - The index to stop copying, exclusive. The last item copied has index end - 1.
public static byte[][] concatArrayArrays(byte[][] first,
byte[][] second)
first - The array of arrays to begin with.second - The array of arrays to end with.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||