public final class SNMP4JSettings
extends java.lang.Object
SNMP4JSettings
class implements a central configuration
class of the SNMP4J framework. As a rule of thumb, changes to the default
configuration should be made before any other classes of the SNMP4J API are
instantiated or referenced by the application code.Modifier and Type | Class and Description |
---|---|
static class |
SNMP4JSettings.ReportSecurityLevelStrategy
Specifies the how the security level of retry requests after a REPORT PDU is
set.
|
Modifier and Type | Field and Description |
---|---|
static int |
AGENTPP_ENTERPRISE_ID
The enterprise ID of AGENT++ which is the root OID also for SNMP4J.
|
private static boolean |
allowSNMPv2InV1
This setting can used to be compatible with some faulty SNMP implementations
which send Counter64 objects with SNMPv1 PDUs.
|
private static int |
enterpriseID
The enterprise ID that is used to build SNMP engine IDs and other enterprise
specific OIDs.
|
private static boolean |
extensibilityEnabled
Specifies whether SNMP4J can be extended by own implementation of
security protocols, transport mappings, address types, SMI syntaxes, etc.
|
private static boolean |
forwardRuntimeExceptions
By default SNMP4J (and SNMP4J-Agent*) catch runtime exceptions at thread
boundaries of API controlled threads.
|
private static int |
maxEngineIdCacheSize
By default allow worth of ~2MB memory for engine ID cache.
|
private static boolean |
noGetBulk
Suppress GETBULK sending.
|
private static OIDTextFormat |
oidTextFormat
By default SNMP4J uses the
SimpleOIDTextFormat to convert
OID s to/from a textual representation. |
private static SNMP4JSettings.ReportSecurityLevelStrategy |
reportSecurityLevelStrategy
This flag enables/disables (default) whether REPORT PDUs should be send by
a command responder with securityLevel
SecurityLevel.noAuthNoPriv
if otherwise the command generator would not able to receive the PDU.REPORT . |
private static ThreadFactory |
threadFactory
By default SNMP4J uses
Thread instances to run
concurrent tasks. |
private static long |
threadJoinTimeout
The default Thread join timeout, used for example by the
DefaultThreadFactory , defines the maximum time to wait for a
Thread running a worker task to end that task (end join the main thread
if that Thread has been exclusively used for that task). |
private static TimerFactory |
timerFactory
By default SNMP4J uses
Timer instances to run
timed tasks. |
private static VariableTextFormat |
variableTextFormat
By default SNMP4J uses the
SimpleVariableTextFormat to convert
VariableBinding s to/from a textual representation. |
Constructor and Description |
---|
SNMP4JSettings() |
Modifier and Type | Method and Description |
---|---|
static int |
getEnterpriseID()
Gets the enterprise OID used for creating SNMP engine IDs and other enterprise
specific identifiers.
|
static int |
getMaxEngineIdCacheSize()
Gets the maximum number of engine IDs to be hold in the cache of the
MPv3 . |
static OIDTextFormat |
getOIDTextFormat()
Gets the OID text format for textual representation of OIDs.
|
static SNMP4JSettings.ReportSecurityLevelStrategy |
getReportSecurityLevelStrategy() |
static ThreadFactory |
getThreadFactory()
Gets the thread factory.
|
static long |
getThreadJoinTimeout()
Gets the Thread join timeout used to join threads if no explicit timeout
is set.
|
static TimerFactory |
getTimerFactory()
Gets the timer factory.
|
static VariableTextFormat |
getVariableTextFormat()
Gets the variable text format for textual representation of variable
bindings.
|
static boolean |
isAllowSNMPv2InV1() |
static boolean |
isExtensibilityEnabled()
Tests if the extensibility feature is enabled.
|
static boolean |
isForwardRuntimeExceptions()
Indicates whether runtime exceptions should be thrown on thread boundaries
controlled by SNMP4J and related APIs.
|
static boolean |
isNoGetBulk() |
static void |
setAllowSNMPv2InV1(boolean allowSNMPv2InV1)
Sets the compatibility flag for Counter64 usage in SNMPv1 PDUs and
the ability to decode SNMPv2 traps in SNMPv1 version PDUs.
|
static void |
setEnterpriseID(int enterpriseID)
Sets the enterprise OID used for creating SNMP engine IDs and other enterprise
specific identifiers.
|
static void |
setExtensibilityEnabled(boolean enable)
Enables (or disables) the extensibility feature of SNMP4J.
|
static void |
setForwardRuntimeExceptions(boolean forwardExceptions)
Enables or disables runtime exception forwarding.
|
static void |
setMaxEngineIdCacheSize(int maxEngineIdCacheSize)
Sets the maximum number of engine IDs that can be cached by the
MPv3 . |
static void |
setNoGetBulk(boolean noGetBulk) |
static void |
setOIDTextFormat(OIDTextFormat newOidTextFormat)
Sets the OID text format to be used by SNMP4J.
|
static void |
setReportSecurityLevelStrategy(SNMP4JSettings.ReportSecurityLevelStrategy reportSecurityLevelStrategy) |
static void |
setThreadFactory(ThreadFactory newThreadFactory)
Sets the thread factory for creating new threads of execution.
|
static void |
setThreadJoinTimeout(long millis)
Sets the Thread join timeout used to join threads if no explicit timeout
is set.
|
static void |
setTimerFactory(TimerFactory newTimerFactory)
Sets the timer factory for creating new timer instances.
|
static void |
setVariableTextFormat(VariableTextFormat newVariableTextFormat)
Sets the variable text format to be used by SNMP4J.
|
public static final int AGENTPP_ENTERPRISE_ID
private static int maxEngineIdCacheSize
private static boolean extensibilityEnabled
false
all classes SNMP4J is aware of will be
used hard coded which speeds up initialization and is required to use
SNMP4J in a secure environment where System properties are not available
(i.e. in an unsigned applet).private static volatile boolean forwardRuntimeExceptions
TransportMapping
and in each Snmp
session object. To ensure
robust runtime behavior, unexpected runtime exceptions are caught and
logged. If you need to localize and debug such exceptions then set this
value to true
.private static ThreadFactory threadFactory
Thread
instances to run
concurrent tasks. For environments with restricted thread management
like Java EE application servers, a custom thread factory can be used.private static TimerFactory timerFactory
Timer
instances to run
timed tasks. For environments with restricted thread management
like Java EE application servers, a custom timer factory can be used.private static OIDTextFormat oidTextFormat
SimpleOIDTextFormat
to convert
OID
s to/from a textual representation.private static VariableTextFormat variableTextFormat
SimpleVariableTextFormat
to convert
VariableBinding
s to/from a textual representation.private static long threadJoinTimeout
DefaultThreadFactory
, defines the maximum time to wait for a
Thread running a worker task to end that task (end join the main thread
if that Thread has been exclusively used for that task). The default value
is 60 seconds (1 min.).private static boolean allowSNMPv2InV1
private static boolean noGetBulk
private static SNMP4JSettings.ReportSecurityLevelStrategy reportSecurityLevelStrategy
SecurityLevel.noAuthNoPriv
if otherwise the command generator would not able to receive the PDU.REPORT
.
RFC 3412 ยง7.6.2.3 requires that the securityLevel is the same as in the confirmed class
PDU if not explicitly otherwise specified.
For SnmpConstants.usmStatsUnsupportedSecLevels
reports, this would
always render the command responder unable to return the report.
Setting this flag to SNMP4JSettings.ReportSecurityLevelStrategy.noAuthNoPrivIfNeeded
reactivates the behavior of SNMP4J prior to v2.2 which sends out the reports with
SecurityLevel.noAuthNoPriv
if otherwise, the report would
not be sent out.private static int enterpriseID
public static void setExtensibilityEnabled(boolean enable)
By default, the extensibility feature is disabled which provides a faster startup and since no system properties are read, it ensures that SNMP4J can be used also in secure environments like applets.
enable
- if true
activates extensibility or if false
disables it. In the latter case, SNMP4J's default configuration will
be used with all available features.public static boolean isExtensibilityEnabled()
true
the extensibility is enabled otherwise it is
disabled. In the latter case, SNMP4J's default configuration will
be used with all available features.public static void setForwardRuntimeExceptions(boolean forwardExceptions)
forwardExceptions
- true
runtime exceptions are thrown on thread boundaries
controlled by SNMP4J and related APIs. Default is false
.forwardRuntimeExceptions
public static boolean isForwardRuntimeExceptions()
true
runtime exceptions are thrown on thread boundaries
controlled by SNMP4J and related APIs. Default is false
.public static ThreadFactory getThreadFactory()
public static void setThreadFactory(ThreadFactory newThreadFactory)
newThreadFactory
- a ThreadFactory (must not be null
).public static TimerFactory getTimerFactory()
public static void setTimerFactory(TimerFactory newTimerFactory)
newTimerFactory
- a TimerFactory (must not be null
).public static OIDTextFormat getOIDTextFormat()
OIDTextFormat
instance.public static void setOIDTextFormat(OIDTextFormat newOidTextFormat)
newOidTextFormat
- the new OIDTextFormat
(must not be null
).public static VariableTextFormat getVariableTextFormat()
VariableTextFormat
instance.public static void setVariableTextFormat(VariableTextFormat newVariableTextFormat)
newVariableTextFormat
- the new VariableTextFormat
(must not be null
).public static long getThreadJoinTimeout()
public static void setThreadJoinTimeout(long millis)
millis
- the maximum time in milli-seconds to wait for a Thread to join if no
explicit timeout has been set.public static boolean isAllowSNMPv2InV1()
public static void setAllowSNMPv2InV1(boolean allowSNMPv2InV1)
false
.
Note: By setting this to true
you disable SNMP standard
conformity.allowSNMPv2InV1
- if set to true
, SNMP4J will allow Counter64 objects
in SNMPv1 PDUs although the SNMPv1 standard does not allow this.
There are several buggy implementations which send such v1 PDUs.public static SNMP4JSettings.ReportSecurityLevelStrategy getReportSecurityLevelStrategy()
public static void setReportSecurityLevelStrategy(SNMP4JSettings.ReportSecurityLevelStrategy reportSecurityLevelStrategy)
public static boolean isNoGetBulk()
public static void setNoGetBulk(boolean noGetBulk)
public static int getEnterpriseID()
public static void setEnterpriseID(int enterpriseID)
enterpriseID
- the new enterprise ID.public static int getMaxEngineIdCacheSize()
MPv3
.
A upper limit is necessary to avoid DoS attacks with unconfirmed SNMPv3 PDUs.public static void setMaxEngineIdCacheSize(int maxEngineIdCacheSize)
MPv3
.maxEngineIdCacheSize
- the maximum number of engine IDs in the cache, by default 50.000 (~2MB of cached data).