com.sun.management.snmp
Class SnmpV3Message

java.lang.Object
  extended by com.sun.management.snmp.SnmpMsg
      extended by com.sun.management.snmp.SnmpV3Message
All Implemented Interfaces:
SnmpDefinitions

public class SnmpV3Message
extends SnmpMsg

Is a partially decoded representation of an SNMP V3 packet.

This class can be used when developing customized manager or agent.

The SnmpV3Message class is directly mapped onto the message syntax defined in RFC 2572.

 SNMPv3Message ::= SEQUENCE {
          msgVersion INTEGER ( 0 .. 2147483647 ),
          -- administrative parameters
          msgGlobalData HeaderData,
          -- security model-specific parameters
          -- format defined by Security Model
          msgSecurityParameters OCTET STRING,
          msgData  ScopedPduData
      }
     HeaderData ::= SEQUENCE {
         msgID      INTEGER (0..2147483647),
         msgMaxSize INTEGER (484..2147483647),

         msgFlags   OCTET STRING (SIZE(1)),
                    --  .... ...1   authFlag
                    --  .... ..1.   privFlag
                    --  .... .1..   reportableFlag
                    --              Please observe:
                    --  .... ..00   is OK, means noAuthNoPriv
                    --  .... ..01   is OK, means authNoPriv
                    --  .... ..10   reserved, must NOT be used.
                    --  .... ..11   is OK, means authPriv

         msgSecurityModel INTEGER (1..2147483647)
     }
 

Since:
Java DMK 5.1

Field Summary
 byte[] contextEngineId
          The context engine Id in which the pdu must be handled (Generally the local engine Id).
 byte[] contextName
          The context name in which the OID has to be interpreted.
 byte[] encryptedPdu
          The encrypted form of the scoped pdu (Only relevant when dealing with privacy).
 byte msgFlags
          Message flags.
 int msgId
          Message identifier.
 int msgMaxSize
          Message max size the pdu sender can deal with.
 int msgSecurityModel
          The security model the security sub system MUST use in order to deal with this pdu (e.g.
 byte[] msgSecurityParameters
          The unmarshalled security parameters.
 
Fields inherited from class com.sun.management.snmp.SnmpMsg
address, data, dataLength, port, securityParameters, version
 
Fields inherited from interface com.sun.management.snmp.SnmpDefinitions
authMask, authNoPriv, authPriv, authPrivMask, CtxtConsFlag, noAuthNoPriv, noGroupName, noSuchContext, noSuchView, notInView, pduGetBulkRequestPdu, pduGetNextRequestPdu, pduGetRequestPdu, pduGetResponsePdu, pduInformRequestPdu, pduReportPdu, pduSetRequestPdu, pduV1TrapPdu, pduV2TrapPdu, pduWalkRequest, privMask, reportableFlag, snmpAuthNotSupported, snmpBadSecurityLevel, snmpPrivNotSupported, snmpReqAborted, snmpReqEncodingError, snmpReqHandleTooBig, snmpReqInternalError, snmpReqPacketOverflow, snmpReqRefireAfterVbFix, snmpReqSocketIOError, snmpReqTimeout, snmpReqTooBigImpossible, snmpReqUnknownError, snmpRspAuthorizationError, snmpRspBadValue, snmpRspCommitFailed, snmpRspDecodingError, snmpRspEndOfTable, snmpRspGenErr, snmpRspInconsistentName, snmpRspInconsistentValue, snmpRspNoAccess, snmpRspNoCreation, snmpRspNoError, snmpRspNoSuchName, snmpRspNotWritable, snmpRspReadOnly, snmpRspResourceUnavailable, snmpRspTooBig, snmpRspUndoFailed, snmpRspWrongEncoding, snmpRspWrongLength, snmpRspWrongType, snmpRspWrongValue, snmpUnknownPrincipal, snmpUsmBadEngineId, snmpUsmInvalidTimeliness, snmpUsmSecurityModel, snmpV1AccessControlModel, snmpV1MsgProcessingModel, snmpV1SecurityModel, snmpV2AccessControlModel, snmpV2MsgProcessingModel, snmpV2SecurityModel, snmpV3AccessControlModel, snmpV3MsgProcessingModel, snmpVersionOne, snmpVersionThree, snmpVersionTwo, snmpWrongSnmpVersion, trapAuthenticationFailure, trapColdStart, trapEgpNeighborLoss, trapEnterpriseSpecific, trapLinkDown, trapLinkUp, trapWarmStart
 
Constructor Summary
SnmpV3Message()
          Constructor.
 
Method Summary
 void decodeMessage(byte[] inputBytes, int byteCount)
          Decodes the specified bytes and initializes this message.
 SnmpPdu decodeSnmpPdu()
          Gets the PDU encoded in this message.
 int encodeMessage(byte[] outputBytes)
          Encodes this message and puts the result in the specified byte array.
 void encodeSnmpPdu(SnmpPdu pdu, int maxDataLength)
          Initializes this message with the specified pdu.
 int getRequestId(byte[] data)
          Returns the associated request Id.
 String printMessage()
          Dumps this message in a string.
 
Methods inherited from class com.sun.management.snmp.SnmpMsg
decodeVarBindList, dumpHexBuffer, encodeVarBindList, getProtocolVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgId

public int msgId
Message identifier.


msgMaxSize

public int msgMaxSize
Message max size the pdu sender can deal with.


msgFlags

public byte msgFlags
Message flags. Reportable flag and security level.

 --  .... ...1   authFlag
 --  .... ..1.   privFlag
 --  .... .1..   reportableFlag
 --              Please observe:
 --  .... ..00   is OK, means noAuthNoPriv
 --  .... ..01   is OK, means authNoPriv
 --  .... ..10   reserved, must NOT be used.
 --  .... ..11   is OK, means authPriv


msgSecurityModel

public int msgSecurityModel
The security model the security sub system MUST use in order to deal with this pdu (e.g. User based Security Model Id = 3).


msgSecurityParameters

public byte[] msgSecurityParameters
The unmarshalled security parameters.


contextEngineId

public byte[] contextEngineId
The context engine Id in which the pdu must be handled (Generally the local engine Id).


contextName

public byte[] contextName
The context name in which the OID has to be interpreted.


encryptedPdu

public byte[] encryptedPdu
The encrypted form of the scoped pdu (Only relevant when dealing with privacy).

Constructor Detail

SnmpV3Message

public SnmpV3Message()
Constructor.

Method Detail

encodeMessage

public int encodeMessage(byte[] outputBytes)
                  throws SnmpTooBigException
Encodes this message and puts the result in the specified byte array. For internal use only.

Specified by:
encodeMessage in class SnmpMsg
Parameters:
outputBytes - An array to receive the resulting encoding.
Throws:
ArrayIndexOutOfBoundsException - If the result does not fit into the specified array.
SnmpTooBigException

decodeMessage

public void decodeMessage(byte[] inputBytes,
                          int byteCount)
                   throws SnmpStatusException
Decodes the specified bytes and initializes this message. For internal use only.

Specified by:
decodeMessage in class SnmpMsg
Parameters:
inputBytes - The bytes to be decoded.
Throws:
SnmpStatusException - If the specified bytes are not a valid encoding.

getRequestId

public int getRequestId(byte[] data)
                 throws SnmpStatusException
Returns the associated request Id.

Specified by:
getRequestId in class SnmpMsg
Parameters:
data - The flat message.
Returns:
The request Id.
Throws:
SnmpStatusException

encodeSnmpPdu

public void encodeSnmpPdu(SnmpPdu pdu,
                          int maxDataLength)
                   throws SnmpStatusException,
                          SnmpTooBigException
Initializes this message with the specified pdu.

This method initializes the data field with an array of maxDataLength bytes. It encodes the pdu. The resulting encoding is stored in the data field and the length of the encoding is stored in dataLength.

If the encoding length exceeds maxDataLength, the method throws an exception.

Specified by:
encodeSnmpPdu in class SnmpMsg
Parameters:
pdu - The PDU to be encoded.
maxDataLength - The maximum length permitted for the data field.
Throws:
SnmpStatusException - If the specified pdu is not valid.
SnmpTooBigException - If the resulting encoding does not fit into maxDataLength bytes.
ArrayIndexOutOfBoundsException - If the encoding exceeds maxDataLength.

decodeSnmpPdu

public SnmpPdu decodeSnmpPdu()
                      throws SnmpStatusException
Gets the PDU encoded in this message.

This method decodes the data field and returns the resulting PDU.

Specified by:
decodeSnmpPdu in class SnmpMsg
Returns:
The resulting PDU.
Throws:
SnmpStatusException - If the encoding is not valid.

printMessage

public String printMessage()
Dumps this message in a string.

Overrides:
printMessage in class SnmpMsg
Returns:
The string containing the dump.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.