net.sf.hermesftp.utils
Class NetUtils

java.lang.Object
  extended by net.sf.hermesftp.utils.NetUtils

public final class NetUtils
extends java.lang.Object

Utility methods that facilitate networking.

Author:
Lars Behnke

Method Summary
static boolean checkIPMatch(java.lang.String ipTemplateList, java.net.InetAddress addr)
          Checks if the passed IP address complies to a given pattern.
static boolean checkIPv4Match(java.lang.String ipTemplateList, java.lang.String ipStr)
          Checks if the passed IPv4 complies to a given pattern.
static boolean checkIPv6Match(java.lang.String ipTemplateList, java.lang.String ipStr)
          Checks if the passed IPv6 complies to a given pattern.
static java.net.InetAddress getMachineAddress(boolean fallBackToLocalhost)
          Returns the machine's network address.
static java.net.InetAddress getMachineAddress(java.net.NetworkInterface ni)
          Returns the network address of a particular network interface.
static boolean isIPv6(java.net.InetAddress addr)
          Checks the IP protocol version (IPv4 or IPv6)
static boolean isSSLAvailable()
          Checks if SSL is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMachineAddress

public static java.net.InetAddress getMachineAddress(boolean fallBackToLocalhost)
Returns the machine's network address.

Parameters:
fallBackToLocalhost - True if loopback address should be used if there is no net.
Returns:
The ip address.

isIPv6

public static boolean isIPv6(java.net.InetAddress addr)
Checks the IP protocol version (IPv4 or IPv6)

Parameters:
addr - The address to check.
Returns:
True, if IPv6.

getMachineAddress

public static java.net.InetAddress getMachineAddress(java.net.NetworkInterface ni)
Returns the network address of a particular network interface.

Parameters:
ni - The network interface.
Returns:
The machine address of a particular network interface.

isSSLAvailable

public static boolean isSSLAvailable()
Checks if SSL is available.

Returns:
True, if SSL is available.

checkIPMatch

public static boolean checkIPMatch(java.lang.String ipTemplateList,
                                   java.net.InetAddress addr)
Checks if the passed IP address complies to a given pattern.

Parameters:
ipTemplateList - String list of patterns. Wild cards are allowed: 192.168.*.*, 127.0.0.1, !85.0.0.0
ip - The IP address to check.
Returns:
True, if the passed IP address matches at least one of the patterns.

checkIPv4Match

public static boolean checkIPv4Match(java.lang.String ipTemplateList,
                                     java.lang.String ipStr)
Checks if the passed IPv4 complies to a given pattern.

Parameters:
ipTemplateList - String list of patterns. Wild cards are allowed: 192.168.*.*, 127.0.0.1, !85.0.0.0
ipStr - The IP address to check.
Returns:
True, if the passed IP address matches at least one of the patterns.

checkIPv6Match

public static boolean checkIPv6Match(java.lang.String ipTemplateList,
                                     java.lang.String ipStr)
Checks if the passed IPv6 complies to a given pattern.

Parameters:
ipTemplateList - String list of patterns. Wild cards are allowed.
ipStr - The IP address to check.
Returns:
True, if the passed IP address matches at least one of the patterns.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.