com.h3c.util.snmp

## Class MsgProcessorV3

- java.lang.Object
- - com.h3c.util.snmp.MsgProcessorV3

-     public class MsgProcessorV3
      extends Object

  SNMP V3 processor implementation. TODO: This code has been redone since pcm but need to have unit tests for 1) device rebooted, engine boots now changed, should get USM error 2) error handling, make sure PDU errors are detected for inconsistent value

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MsgProcessorV3()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `configureForRequest(SnmpRequest request)` Configure the message as request according to the specific processor.
    `void` | `configureForTrap(SnmpRequest trap)` Configure the message as trap according to the specific processor.
    `boolean` | `decryptResponse(SnmpTarget requestTarget, SnmpResponse response)` Performs decryption on the response message using the security information from the request target.
    `boolean` | `parseResponse(SnmpResponse response)` First pass handling of a newly decoded response.
    `boolean` | `prepareRequestForEncoding(SnmpRequest request, int requestId)` This should be called right before a request is to be encoded and written to a channel.
    `void` | `repairRequestAfterEncoding(SnmpRequest request)` This method overridden by a processor to repair anything done to the request in the call to `MsgProcessor.prepareRequestForEncoding(SnmpRequest, int)`.
    `boolean` | `updateTargetFromDiscoveryResponse(SnmpTarget requestTarget, SnmpResponse discoveryResponse)` Use this call back to update the USM parameter data in the discovery response to the target of the original request.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MsgProcessorV3

          public MsgProcessorV3()

  - ### Method Detail

    - #### prepareRequestForEncoding

          public boolean prepareRequestForEncoding(SnmpRequest request,
                                          int requestId)

      This should be called right before a request is to be encoded and written to a channel. This is after the request has been filled in with variable bindings and after the request ID has been allocated. Here is where you attach the request ID, setup security, perform encryption, etc.
      Parameters:
        `request` - SNMP request to be prepared
        `requestId` - allocated request ID for this message
      Returns:
        true if the request was in proper form, if false is returned the request error will be set

    - #### repairRequestAfterEncoding

          public void repairRequestAfterEncoding(SnmpRequest request)

      This method overridden by a processor to repair anything done to the request in the call to `MsgProcessor.prepareRequestForEncoding(SnmpRequest, int)`. For example, the V3 processor will return the request back to the non-encrypted form.
      Parameters:
        `request` - SNMP request to be repaired

    - #### parseResponse

          public boolean parseResponse(SnmpResponse response)

      First pass handling of a newly decoded response. Sets up the PDU reference with in the message and determines the request ID. No decryption can be performed here as we don't know the original request.
      Parameters:
        `response` - SNMP response to parse
      Returns:
        true if the parse completed successfully, the request ID may still be valid even if this method returns false because some parsing errors occur after request ID retrieval

    - #### decryptResponse

          public boolean decryptResponse(SnmpTarget requestTarget,
                                SnmpResponse response)

      Performs decryption on the response message using the security information from the request target. Processors that don't perform should return true.
      Parameters:
        `requestTarget` - SNMP target of the original request
        `response` - SNMP response message.
      Returns:
        true if the message was successfully decrypted or the processor does not perform encryption

    - #### configureForRequest

          public void configureForRequest(SnmpRequest request)

      Configure the message as request according to the specific processor.
      Parameters:
        `request` - SNMP request to be configured

    - #### configureForTrap

          public void configureForTrap(SnmpRequest trap)

      Configure the message as trap according to the specific processor.
      Parameters:
        `trap` - SNMP request to be configured

    - #### updateTargetFromDiscoveryResponse

          public boolean updateTargetFromDiscoveryResponse(SnmpTarget requestTarget,
                                                  SnmpResponse discoveryResponse)

      Use this call back to update the USM parameter data in the discovery response to the target of the original request. Ignore the USM error in a discovery response.
      Parameters:
        `requestTarget` - original SNMP request target
        `discoveryResponse` - discovery SNMP response (must have valid USM param object)
      Returns:
        true if the target was updated

Copyright © 2014. All Rights Reserved.