Class DefaultMOInput
java.lang.Object
org.snmp4j.agent.io.DefaultMOInput
- All Implemented Interfaces:
MOInput
The
DefaultMOInput class implements the MOInput interface to provide functionality
for reading managed object states, variables, and other elements from a persistent source
using an ObjectInputStream. It uses strict deserialization filters to ensure
that only authorized classes are read, improving the security and consistency of input handling.- Version:
- 3.12.0
- Author:
- Frank Fock
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aDefaultMOInputfor the suppliedObjectInputStreamand installs a strictAgentStateDeserializationFilteron it that allows only the agent state classes written byDefaultMOOutputto be deserialized.DefaultMOInput(ObjectInputStream ois, Collection<Class<?>> additionalAllowedClasses) Creates aDefaultMOInputfor the suppliedObjectInputStreamand installs a strictAgentStateDeserializationFilteron it that allows the agent state classes written byDefaultMOOutputplus the supplied additional classes to be deserialized. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intReturns the update mode, which might be one of the constants defined byImportMode.Reads and returns aContextfrom the input source.Reads and returns anIndexedVariablesinstance from the input source.Reads and returns aMOInfoobject from the input source.Reads and returns aSequencefrom the input source.org.snmp4j.smi.VariableReads aVariablefrom the input source.voidsetOverwriteMode(int importMode) voidskipContext(Context context) Skips the specifiedContextduring the reading process.voidskipManagedObject(MOInfo moInfo) Skips to the end of the specified managed object's configuration.
-
Constructor Details
-
DefaultMOInput
Creates aDefaultMOInputfor the suppliedObjectInputStreamand installs a strictAgentStateDeserializationFilteron it that allows only the agent state classes written byDefaultMOOutputto be deserialized.- Parameters:
ois- theObjectInputStreamto read the persistent agent state from.
-
DefaultMOInput
Creates aDefaultMOInputfor the suppliedObjectInputStreamand installs a strictAgentStateDeserializationFilteron it that allows the agent state classes written byDefaultMOOutputplus the supplied additional classes to be deserialized. Use this constructor to restore persistent state that contains custom (e.g. user defined)VariableorContextsubclasses.- Parameters:
ois- theObjectInputStreamto read the persistent agent state from.additionalAllowedClasses- additional classes (matched by exact identity) to allow for deserialization in addition to the default agent state classes, ornull/empty for the default set only.- Since:
- 3.9.0
-
-
Method Details
-
getImportMode
public int getImportMode()Description copied from interface:MOInputReturns the update mode, which might be one of the constants defined byImportMode.- Specified by:
getImportModein interfaceMOInput- Returns:
- the constant denoting the update mode that should be used by a
SerializableManagedObjectto import its content from persistent storage.
-
readContext
Description copied from interface:MOInputReads and returns aContextfrom the input source.- Specified by:
readContextin interfaceMOInput- Returns:
- a
Contextinstance representing the context information extracted from the input source. - Throws:
IOException- if an error occurs while reading theContext.
-
readIndexedVariables
Description copied from interface:MOInputReads and returns anIndexedVariablesinstance from the input source. AnIndexedVariablesobject encapsulates an index and an array of variables, providing a structured representation of indexed row data.- Specified by:
readIndexedVariablesin interfaceMOInput- Returns:
- an
IndexedVariablesinstance representing the indexed row data read from the input. - Throws:
IOException- if an I/O error occurs while reading the input source.
-
readManagedObject
Description copied from interface:MOInputReads and returns aMOInfoobject from the input source. AMOInfoinstance encapsulates information about a managed object, including its unique identifier (OID) and version details.- Specified by:
readManagedObjectin interfaceMOInput- Returns:
- a
MOInfoinstance representing the managed object information read from the input source. - Throws:
IOException- if an I/O error occurs while reading the managed object.
-
readSequence
Description copied from interface:MOInputReads and returns aSequencefrom the input source.- Specified by:
readSequencein interfaceMOInput- Returns:
- a
Sequenceobject representing the data read from the input source. - Throws:
IOException- if an I/O error occurs while reading theSequence.
-
readVariable
Description copied from interface:MOInputReads aVariablefrom the input source.- Specified by:
readVariablein interfaceMOInput- Returns:
- a
Variableobject representing the data read from the input source. - Throws:
IOException- if an I/O error occurs while reading theVariable.
-
skipContext
Description copied from interface:MOInputSkips the specifiedContextduring the reading process. This method is used to bypass a context in the input stream without processing it.- Specified by:
skipContextin interfaceMOInput- Parameters:
context- theContextinstance to be skipped. This represents specific context information that is available in the input.- Throws:
IOException- if an I/O error occurs while attempting to skip the context in the input stream.
-
skipManagedObject
Description copied from interface:MOInputSkips to the end of the specified managed object's configuration.- Specified by:
skipManagedObjectin interfaceMOInput- Parameters:
moInfo- a MOInfo instance.- Throws:
IOException- if the input stream cannot be read.
-
setOverwriteMode
public void setOverwriteMode(int importMode) -
close
- Specified by:
closein interfaceMOInput- Throws:
IOException
-