Class UsmTimeTable
java.lang.Object
org.snmp4j.security.UsmTimeTable
- All Implemented Interfaces:
Serializable
The
UsmTimeTable class stores USM user information as part of the Local Configuration Datastore (LCD).- Version:
- 1.2
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntry(UsmTimeEntry entry) intcheckEngineID(OctetString engineID, boolean discoveryAllowed, int engineBoots, int engineTime) intcheckTime(UsmTimeEntry entry) Checks the time window of a received message as defined by RFC 3414 §3.2.7 and updates the time synchronization information of the sending engine accordingly.intThe number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was last configured.intReturns the number of seconds since the value of the engineBoots object last changed.getEntry(OctetString engineID) intGets the maximum number of entries created by engine discovery that are kept in this table.getTime(OctetString engineID) voidremoveEntry(OctetString engineID) Removes the specified engine ID from the time cache.voidreset()voidsetEngineBoots(int engineBoots) Sets the number of engine boots.voidsetLocalTime(UsmTimeEntry localTime) voidsetMaxDiscoveredEntries(int maxDiscoveredEntries) Sets the maximum number of entries created by engine discovery that are kept in this table.
-
Field Details
-
USM_MAX_TIME_DIFFERENCE_HUNDREDS
public static final int USM_MAX_TIME_DIFFERENCE_HUNDREDS- See Also:
-
-
Constructor Details
-
UsmTimeTable
-
-
Method Details
-
addEntry
-
getEntry
-
getLocalTime
-
setLocalTime
-
setEngineBoots
public void setEngineBoots(int engineBoots) Sets the number of engine boots.- Parameters:
engineBoots- the number of engine boots.- Since:
- 1.2
-
getEngineTime
public int getEngineTime()Returns the number of seconds since the value of the engineBoots object last changed. When incrementing this object's value would cause it to exceed its maximum, engineBoots is incremented as if a re-initialization had occurred, and this object's value consequently reverts to zero.- Returns:
- a positive integer value denoting the number of seconds since the engineBoots value has been changed.
- Since:
- 1.2
-
getEngineBoots
public int getEngineBoots()The number of times that the SNMP engine has (re-)initialized itself since snmpEngineID was last configured.- Returns:
- the number of SNMP engine reboots.
-
getTime
-
removeEntry
Removes the specified engine ID from the time cache.- Parameters:
engineID- the engine ID of the remote SNMP engine to remove from this time cache.
-
getMaxDiscoveredEntries
public int getMaxDiscoveredEntries()Gets the maximum number of entries created by engine discovery that are kept in this table.checkEngineID(OctetString, boolean, int, int)is the only writer of this table that is reached before a received message has been authenticated, so without a limit any peer could grow this table without bound by sending unauthenticated messages with an ever changing authoritative engine ID.- Returns:
- the maximum number of discovered entries, or 0 if their number is not limited. The default is
SNMP4JSettings.getMaxEngineIdCacheSize()at the time this table has been created. - Since:
- 3.13.0
-
setMaxDiscoveredEntries
public void setMaxDiscoveredEntries(int maxDiscoveredEntries) Sets the maximum number of entries created by engine discovery that are kept in this table. Entries added withaddEntry(UsmTimeEntry)- for example for a target this entity sends a request to - and entries that have been synchronized by an authenticated message are neither counted nor evicted, so that unauthenticated traffic cannot displace them.- Parameters:
maxDiscoveredEntries- the maximum number of discovered entries, or 0 to not limit their number.- Since:
- 3.13.0
-
checkEngineID
public int checkEngineID(OctetString engineID, boolean discoveryAllowed, int engineBoots, int engineTime) -
checkTime
Checks the time window of a received message as defined by RFC 3414 §3.2.7 and updates the time synchronization information of the sending engine accordingly.This method must only be called for messages whose authentication digest has been verified. RFC 3414 §3.2.7 is scoped to authenticated messages, and this method marks the time entry of the sending engine as synchronized, which protects it from being evicted as a discovery placeholder.
- Parameters:
entry- the engine ID, engine boots, and engine time received with the authenticated message.- Returns:
SnmpConstants.SNMPv3_USM_OKif the message is inside the time window,SnmpConstants.SNMPv3_USM_NOT_IN_TIME_WINDOWif it is not, andSnmpConstants.SNMPv3_USM_UNKNOWN_ENGINEIDif the engine ID is not known.
-
reset
public void reset()
-