org.opensaml.xml.util
Class IPAddressHelper

java.lang.Object
  extended by org.opensaml.xml.util.IPAddressHelper

public final class IPAddressHelper
extends Object

Helper class for working with IP address data.


Constructor Summary
private IPAddressHelper()
          Constructor.
 
Method Summary
static String addressToString(byte[] address)
          Convert the byte array representation of an IP address into a string.
private static Logger getLogger()
          Get an SLF4J Logger.
static boolean hasMask(byte[] address)
          Check whether IP address array has a subnet mask or not.
private static String ipv4ToString(byte[] address)
          Convert the byte array representation of an IPv4 address into a string.
private static String ipv6ToString(byte[] address)
          Convert the byte array representation of an IPv6 address into a string.
static boolean isIPv4(byte[] address)
          Check whether IP address array is IPv4.
static boolean isIPv6(byte[] address)
          Check whether IP address array is IPv6.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IPAddressHelper

private IPAddressHelper()
Constructor.

Method Detail

addressToString

public static String addressToString(byte[] address)
Convert the byte array representation of an IP address into a string. Supports IPv4 and IPv6 addresses. Supports optional subnet mask stored within the same byte array. If the latter is present, output will be: "ipAddr/mask".

Parameters:
address - IP address in byte array form (in network byte order)
Returns:
IP address as a string, or null if can not be processed

ipv4ToString

private static String ipv4ToString(byte[] address)
Convert the byte array representation of an IPv4 address into a string. Supports optional subnet mask stored within the same byte array. If the latter is present, output will be: "ipAddr/mask".

Parameters:
address - IP address in byte array form (in network byte order)
Returns:
IP address as a string, or null if can not be processed

ipv6ToString

private static String ipv6ToString(byte[] address)
Convert the byte array representation of an IPv6 address into a string. Supports optional subnet mask stored within the same byte array. If the latter is present, output will be: "ipAddr/mask".

Parameters:
address - IP address in byte array form (in network byte order)
Returns:
IP address as a string, or null if can not be processed

isIPv4

public static boolean isIPv4(byte[] address)
Check whether IP address array is IPv4.

Parameters:
address - IP address byte array
Returns:
true if IPv4, false otherwise

isIPv6

public static boolean isIPv6(byte[] address)
Check whether IP address array is IPv6.

Parameters:
address - IP address byte array
Returns:
true if IPv6, false otherwise

hasMask

public static boolean hasMask(byte[] address)
Check whether IP address array has a subnet mask or not.

Parameters:
address - IP address byte array
Returns:
true if has subnet mask, false otherwise

getLogger

private static Logger getLogger()
Get an SLF4J Logger.

Returns:
a Logger instance


Copyright © 1999-2013. All Rights Reserved.