net.logAnalyzer.utils
Class WhoIs

java.lang.Object
  extended bynet.logAnalyzer.utils.WhoIs

public class WhoIs
extends java.lang.Object

This class implements the "Who Is" resolution for IP addresses (IP v4 and IP v6). It uses a file based cache if exists to increase resolution speed.

Beware than the cache file is not updated until you call saveWhoIsCache().

Version:
0.1
Author:
Karim REFEYTON

Field Summary
static java.lang.String[] WHOIS_SERVERS_IP
          WhoIs servers IP.
static java.lang.String[] WHOIS_SERVERS_NAMES
          WhoIs servers names.
 
Constructor Summary
WhoIs(java.lang.String address)
          Constructs a new WhoIs resolution for the specified address.
WhoIs(java.lang.String address, java.lang.String whoIsServerName)
          Constructs a new WhoIs resolution for the specified address.
 
Method Summary
 java.lang.String getAddress()
          Returns the address to resolve.
 java.lang.String getCIDR()
          Returns the CIDR address.
 java.lang.String getCountry()
          Returns the coutrny.
 java.lang.String getFullResponse()
          Returns the full response of the WhoIs server.
 java.net.InetAddress getInetAddress()
          Returns the address to resolve.
 java.lang.String getNetName()
          Returns the network name.
 java.lang.String getNetName(java.lang.String response)
          Returns the network name.
 java.lang.String getOrgName()
          Returns the organization name.
 java.lang.String getWhoIsServerIP()
          Returns the IP of the server used to resolve the address.
 java.lang.String getWhoIsServerName()
          Returns the name of the server used to resolve the address.
 boolean isNew()
          Returns true is a new address (ie if the address was not in cache).
static void saveWhoIsCache()
          Saves WhoIs cache to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WHOIS_SERVERS_NAMES

public static final java.lang.String[] WHOIS_SERVERS_NAMES
WhoIs servers names. List of WhoIs servers :


WHOIS_SERVERS_IP

public static final java.lang.String[] WHOIS_SERVERS_IP
WhoIs servers IP.

Constructor Detail

WhoIs

public WhoIs(java.lang.String address)
      throws java.net.UnknownHostException
Constructs a new WhoIs resolution for the specified address. Uses only known WhoIs servers WHOIS_SERVERS_NAMES.

Parameters:
address - Address to resolve.

WhoIs

public WhoIs(java.lang.String address,
             java.lang.String whoIsServerName)
      throws java.net.UnknownHostException
Constructs a new WhoIs resolution for the specified address. Uses first the specified whoIsServerName and, if not found, the known WhoIs servers WHOIS_SERVERS_NAMES.

Parameters:
address - Address to resolve.
whoIsServerName - WhoIs server to use first.
Method Detail

saveWhoIsCache

public static void saveWhoIsCache()
Saves WhoIs cache to a file. The file name is #WHOISCACHE_FILENAME.


getAddress

public java.lang.String getAddress()
Returns the address to resolve.

Returns:
IP address to resolve in String format.

getInetAddress

public java.net.InetAddress getInetAddress()
Returns the address to resolve.

Returns:
IP address to resolve.

getWhoIsServerIP

public java.lang.String getWhoIsServerIP()
Returns the IP of the server used to resolve the address.

Returns:
WhoIs server IP.

getWhoIsServerName

public java.lang.String getWhoIsServerName()
Returns the name of the server used to resolve the address.

Returns:
WhoIs server name.

getFullResponse

public java.lang.String getFullResponse()
Returns the full response of the WhoIs server.

Returns:
Full response.

getCIDR

public java.lang.String getCIDR()
Returns the CIDR address. Looks at CIDR or route information.

Returns:
Orgnization name.

getCountry

public java.lang.String getCountry()
Returns the coutrny. Looks at coutrny or net-name information.

Returns:
Country.

getNetName

public java.lang.String getNetName()
Returns the network name. Looks at netname or net-name information.

Returns:
Orgnization name.

getNetName

public java.lang.String getNetName(java.lang.String response)
Returns the network name. Looks at netname or net-name information.

Parameters:
response - Response to parse.
Returns:
Orgnization name.

getOrgName

public java.lang.String getOrgName()
Returns the organization name. Looks at org-name or orgname or the first descr information.

Returns:
Orgnization name.

isNew

public boolean isNew()
Returns true is a new address (ie if the address was not in cache).

Returns:
true if it is a new address; false otherwise.


Copyright © 2006 null. All Rights Reserved.