Class DefaultMOInput

java.lang.Object
org.snmp4j.agent.io.DefaultMOInput
All Implemented Interfaces:
MOInput

public class DefaultMOInput extends Object implements 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 Details

    • DefaultMOInput

      public DefaultMOInput(ObjectInputStream ois)
      Creates a DefaultMOInput for the supplied ObjectInputStream and installs a strict AgentStateDeserializationFilter on it that allows only the agent state classes written by DefaultMOOutput to be deserialized.
      Parameters:
      ois - the ObjectInputStream to read the persistent agent state from.
    • DefaultMOInput

      public DefaultMOInput(ObjectInputStream ois, Collection<Class<?>> additionalAllowedClasses)
      Creates a DefaultMOInput for the supplied ObjectInputStream and installs a strict AgentStateDeserializationFilter on it that allows the agent state classes written by DefaultMOOutput plus the supplied additional classes to be deserialized. Use this constructor to restore persistent state that contains custom (e.g. user defined) Variable or Context subclasses.
      Parameters:
      ois - the ObjectInputStream to 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, or null/empty for the default set only.
      Since:
      3.9.0
  • Method Details

    • getImportMode

      public int getImportMode()
      Description copied from interface: MOInput
      Returns the update mode, which might be one of the constants defined by ImportMode.
      Specified by:
      getImportMode in interface MOInput
      Returns:
      the constant denoting the update mode that should be used by a SerializableManagedObject to import its content from persistent storage.
    • readContext

      public Context readContext() throws IOException
      Description copied from interface: MOInput
      Reads and returns a Context from the input source.
      Specified by:
      readContext in interface MOInput
      Returns:
      a Context instance representing the context information extracted from the input source.
      Throws:
      IOException - if an error occurs while reading the Context.
    • readIndexedVariables

      public IndexedVariables readIndexedVariables() throws IOException
      Description copied from interface: MOInput
      Reads and returns an IndexedVariables instance from the input source. An IndexedVariables object encapsulates an index and an array of variables, providing a structured representation of indexed row data.
      Specified by:
      readIndexedVariables in interface MOInput
      Returns:
      an IndexedVariables instance representing the indexed row data read from the input.
      Throws:
      IOException - if an I/O error occurs while reading the input source.
    • readManagedObject

      public MOInfo readManagedObject() throws IOException
      Description copied from interface: MOInput
      Reads and returns a MOInfo object from the input source. A MOInfo instance encapsulates information about a managed object, including its unique identifier (OID) and version details.
      Specified by:
      readManagedObject in interface MOInput
      Returns:
      a MOInfo instance representing the managed object information read from the input source.
      Throws:
      IOException - if an I/O error occurs while reading the managed object.
    • readSequence

      public Sequence readSequence() throws IOException
      Description copied from interface: MOInput
      Reads and returns a Sequence from the input source.
      Specified by:
      readSequence in interface MOInput
      Returns:
      a Sequence object representing the data read from the input source.
      Throws:
      IOException - if an I/O error occurs while reading the Sequence.
    • readVariable

      public org.snmp4j.smi.Variable readVariable() throws IOException
      Description copied from interface: MOInput
      Reads a Variable from the input source.
      Specified by:
      readVariable in interface MOInput
      Returns:
      a Variable object representing the data read from the input source.
      Throws:
      IOException - if an I/O error occurs while reading the Variable.
    • skipContext

      public void skipContext(Context context) throws IOException
      Description copied from interface: MOInput
      Skips the specified Context during the reading process. This method is used to bypass a context in the input stream without processing it.
      Specified by:
      skipContext in interface MOInput
      Parameters:
      context - the Context instance 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

      public void skipManagedObject(MOInfo moInfo) throws IOException
      Description copied from interface: MOInput
      Skips to the end of the specified managed object's configuration.
      Specified by:
      skipManagedObject in interface MOInput
      Parameters:
      moInfo - a MOInfo instance.
      Throws:
      IOException - if the input stream cannot be read.
    • setOverwriteMode

      public void setOverwriteMode(int importMode)
    • close

      public void close() throws IOException
      Specified by:
      close in interface MOInput
      Throws:
      IOException