OpenNMS API 1.2.3

org.opennms.netmgt.config
Class VulnscandConfigFactory

java.lang.Object
  extended byorg.opennms.netmgt.config.VulnscandConfigFactory

public final class VulnscandConfigFactory
extends java.lang.Object

This is the singleton class used to load the configuration for the OpenNMS Vulnscand service from the vulnscand-configuration xml file. Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods.

Author:
Seth Leger , Mike Davidson , Weave , OpenNMS

Field Summary
private static char COMMENT_CHAR
          This character at the start of a line indicates a comment line in a URL file
private static java.lang.String COMMENT_STR
          The string indicating the start of the comments in a line containing the IP address in a file URL
private static VulnscandConfiguration m_config
          The config class loaded from the config file
private static java.util.Set m_excludes
          Cached set of the excluded IP addresses
private static boolean m_loaded
          This member is set to true if the configuration file has been loaded.
private static java.lang.String[] m_pluginLists
          Cached value of the plugin lists for each scan level
private static boolean[] m_safeChecks
          Cached value of the "safe checks" values for each scan level
private static VulnscandConfigFactory m_singleton
          The singleton instance of this factory
private static org.apache.regexp.RE m_space
          Whitespace regex
private static java.lang.String RETRIEVE_IPADDR_NODEID_SQL
          The SQL statement used to determine if an IP address is already in the ipInterface table and if so what its parent nodeid is.
private static java.lang.String RETRIEVE_IPADDR_SQL
          The SQL statement used to determine if an IP address is already in the ipInterface table and there is known.
 
Constructor Summary
private VulnscandConfigFactory(java.lang.String configFile)
          Constructs a new VulnscandConfigFactory object for access to the Vulnscand configuration information.
 
Method Summary
 void addRange(int level, java.net.InetAddress begin, java.net.InetAddress end)
           
 void addRange(ScanLevel level, java.net.InetAddress begin, java.net.InetAddress end)
           
 void addSpecific(int level, java.net.InetAddress specific)
           
 void addSpecific(ScanLevel level, java.net.InetAddress specific)
           
 java.util.Set getAllExcludes()
           
 java.util.Set getAllIpAddresses(int level)
           
 java.util.Set getAllIpAddresses(ScanLevel level)
           
static VulnscandConfiguration getConfiguration()
          Return the Vulnscand configuration object.
 long getInitialSleepTime()
           
static VulnscandConfigFactory getInstance()
          Return the singleton instance of this factory.
static int getInterfaceDbNodeId(java.sql.Connection dbConn, java.net.InetAddress ifAddress)
           
 int getManagedInterfacesScanLevel()
           
 boolean getManagedInterfacesStatus()
           
 int getMaxRescanThreadPoolSize()
           
 int getMaxSuspectThreadPoolSize()
           
 java.lang.String[] getPluginLists()
          Gets the cached value of the plugin lists in the config file
 long getRescanFrequency()
           
 boolean[] getSafeChecks()
          Gets the cached value of the safe checks settings in the config file
private static ScanLevel getScanLevel(int level)
           
 java.net.InetAddress getServerAddress()
           
 java.lang.String getServerPassword()
           
 int getServerPort()
           
 java.lang.String getServerUsername()
           
 boolean getStatus()
           
static void init()
          Load the config from the default config file and create the singleton instance of this factory.
static boolean isInterfaceInDB(java.sql.Connection dbConn, java.net.InetAddress ifAddress)
           
static void reload()
          Reload the config from the default config file
 void removeExcludeRange(java.net.InetAddress begin, java.net.InetAddress end)
           
 void removeExcludeSpecific(java.net.InetAddress specific)
           
 void removeRange(int level, java.net.InetAddress begin, java.net.InetAddress end)
           
 void removeRange(ScanLevel level, java.net.InetAddress begin, java.net.InetAddress end)
           
 void removeSpecific(int level, java.net.InetAddress specific)
           
 void removeSpecific(ScanLevel level, java.net.InetAddress specific)
           
static void saveCurrent()
          Saves the current settings to disk
static java.net.InetAddress toInetAddress(long address)
           Converts a 64-bit unsigned quantity to a IPv4 dotted decimal string address.
static long toLong(java.net.InetAddress addr)
          Deprecated. See org.opennms.core.utils.InetAddressCollection.toLong(InetAddress addr)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMENT_STR

private static final java.lang.String COMMENT_STR
The string indicating the start of the comments in a line containing the IP address in a file URL

See Also:
Constant Field Values

COMMENT_CHAR

private static final char COMMENT_CHAR
This character at the start of a line indicates a comment line in a URL file

See Also:
Constant Field Values

m_loaded

private static boolean m_loaded
This member is set to true if the configuration file has been loaded.


m_singleton

private static VulnscandConfigFactory m_singleton
The singleton instance of this factory


m_config

private static VulnscandConfiguration m_config
The config class loaded from the config file


m_pluginLists

private static java.lang.String[] m_pluginLists
Cached value of the plugin lists for each scan level


m_safeChecks

private static boolean[] m_safeChecks
Cached value of the "safe checks" values for each scan level


m_excludes

private static java.util.Set m_excludes
Cached set of the excluded IP addresses


m_space

private static org.apache.regexp.RE m_space
Whitespace regex


RETRIEVE_IPADDR_SQL

private static final java.lang.String RETRIEVE_IPADDR_SQL
The SQL statement used to determine if an IP address is already in the ipInterface table and there is known.

See Also:
Constant Field Values

RETRIEVE_IPADDR_NODEID_SQL

private static final java.lang.String RETRIEVE_IPADDR_NODEID_SQL
The SQL statement used to determine if an IP address is already in the ipInterface table and if so what its parent nodeid is.

See Also:
Constant Field Values
Constructor Detail

VulnscandConfigFactory

private VulnscandConfigFactory(java.lang.String configFile)
                        throws java.io.IOException,
                               org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException
Constructs a new VulnscandConfigFactory object for access to the Vulnscand configuration information.

Parameters:
configFile - The configuration file to load.
Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.
Method Detail

init

public static void init()
                 throws java.io.IOException,
                        org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException
Load the config from the default config file and create the singleton instance of this factory.

Throws:
java.io.IOException - Thrown if the specified config file cannot be read
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

reload

public static void reload()
                   throws java.io.IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException
Reload the config from the default config file

Throws:
java.io.IOException - Thrown if the specified config file cannot be read/loaded
org.exolab.castor.xml.MarshalException - Thrown if the file does not conform to the schema.
org.exolab.castor.xml.ValidationException - Thrown if the contents do not match the required schema.

saveCurrent

public static void saveCurrent()
                        throws java.lang.Exception
Saves the current settings to disk

Throws:
java.lang.Exception

getInstance

public static VulnscandConfigFactory getInstance()
Return the singleton instance of this factory.

Returns:
The current factory instance.
Throws:
java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.

getConfiguration

public static VulnscandConfiguration getConfiguration()
Return the Vulnscand configuration object.


toLong

public static long toLong(java.net.InetAddress addr)
Deprecated. See org.opennms.core.utils.InetAddressCollection.toLong(InetAddress addr)

This method is used to convert the passed IP address to a long value. The address is converted in network byte order (big endin). This is compatable with the number format of the JVM, and thus the return longs can be compared with other converted IP Addresses to determine inclusion.

Parameters:
addr - The IP address to convert.
Returns:
The converted IP address.

toInetAddress

public static java.net.InetAddress toInetAddress(long address)
                                          throws java.net.UnknownHostException

Converts a 64-bit unsigned quantity to a IPv4 dotted decimal string address.

Parameters:
address - The 64-bit quantity to convert.
Returns:
The dotted decimal IPv4 address string.
Throws:
java.net.UnknownHostException

isInterfaceInDB

public static boolean isInterfaceInDB(java.sql.Connection dbConn,
                                      java.net.InetAddress ifAddress)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getInterfaceDbNodeId

public static int getInterfaceDbNodeId(java.sql.Connection dbConn,
                                       java.net.InetAddress ifAddress)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

getScanLevel

private static ScanLevel getScanLevel(int level)

addSpecific

public void addSpecific(int level,
                        java.net.InetAddress specific)

addSpecific

public void addSpecific(ScanLevel level,
                        java.net.InetAddress specific)

addRange

public void addRange(int level,
                     java.net.InetAddress begin,
                     java.net.InetAddress end)

addRange

public void addRange(ScanLevel level,
                     java.net.InetAddress begin,
                     java.net.InetAddress end)

removeSpecific

public void removeSpecific(int level,
                           java.net.InetAddress specific)

removeSpecific

public void removeSpecific(ScanLevel level,
                           java.net.InetAddress specific)

removeRange

public void removeRange(int level,
                        java.net.InetAddress begin,
                        java.net.InetAddress end)

removeRange

public void removeRange(ScanLevel level,
                        java.net.InetAddress begin,
                        java.net.InetAddress end)

getAllIpAddresses

public java.util.Set getAllIpAddresses(int level)

getAllIpAddresses

public java.util.Set getAllIpAddresses(ScanLevel level)

getAllExcludes

public java.util.Set getAllExcludes()

removeExcludeRange

public void removeExcludeRange(java.net.InetAddress begin,
                               java.net.InetAddress end)

removeExcludeSpecific

public void removeExcludeSpecific(java.net.InetAddress specific)

getRescanFrequency

public long getRescanFrequency()

getInitialSleepTime

public long getInitialSleepTime()

getServerAddress

public java.net.InetAddress getServerAddress()

getPluginLists

public java.lang.String[] getPluginLists()
Gets the cached value of the plugin lists in the config file


getSafeChecks

public boolean[] getSafeChecks()
Gets the cached value of the safe checks settings in the config file


getServerPort

public int getServerPort()

getServerUsername

public java.lang.String getServerUsername()

getServerPassword

public java.lang.String getServerPassword()

getStatus

public boolean getStatus()

getManagedInterfacesStatus

public boolean getManagedInterfacesStatus()

getManagedInterfacesScanLevel

public int getManagedInterfacesScanLevel()

getMaxSuspectThreadPoolSize

public int getMaxSuspectThreadPoolSize()

getMaxRescanThreadPoolSize

public int getMaxRescanThreadPoolSize()

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.