Package org.opennms.pris.util
Class InterfaceUtils
java.lang.Object
org.opennms.pris.util.InterfaceUtils
- Direct Known Subclasses:
OcsInterfaceUtils
Maintains IP black- and white-lists and matches IP addresses against them
using IPLike patterns.
-
Constructor Summary
ConstructorsConstructorDescriptionInterfaceUtils(InstanceConfiguration config) Creates interface utilities bound to the given instance configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIpBlack(String ip) Adds an IPLike pattern to the black-list.voidaddIpWhite(String ip) Adds an IPLike pattern to the white-list.voidLoads the black- and white-lists from theblackList.propertiesandwhiteList.propertiesfiles in the working directory, falling back to empty lists if the files cannot be read.isIpBlackListed(String ipAddress) Checks whether the given IP address matches any entry on the black-list.isIpWhiteListed(String ipAddress) Checks whether the given IP address matches any entry on the white-list.
-
Constructor Details
-
InterfaceUtils
Creates interface utilities bound to the given instance configuration.- Parameters:
config- the configuration of the requisition instance
-
-
Method Details
-
isIpBlackListed
Checks whether the given IP address matches any entry on the black-list.- Parameters:
ipAddress- the IP address to test- Returns:
trueif the address matches a black-list entry
-
isIpWhiteListed
Checks whether the given IP address matches any entry on the white-list.- Parameters:
ipAddress- the IP address to test- Returns:
trueif the address matches a white-list entry
-
addIpWhite
Adds an IPLike pattern to the white-list. Entries with invalid syntax are rejected and logged rather than added.- Parameters:
ip- the IPLike pattern to add
-
addIpBlack
Adds an IPLike pattern to the black-list. Entries with invalid syntax are rejected and logged rather than added.- Parameters:
ip- the IPLike pattern to add
-
initListsFromConfigs
public void initListsFromConfigs()Loads the black- and white-lists from theblackList.propertiesandwhiteList.propertiesfiles in the working directory, falling back to empty lists if the files cannot be read.
-