com.adventnet.snmp.snmp2
Class Snmp3Message

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SnmpMessage
        |
        +--com.adventnet.snmp.snmp2.Snmp3Message
All Implemented Interfaces:
java.io.Serializable

public class Snmp3Message
extends SnmpMessage
implements java.io.Serializable

This class encapsulates a v3 message. The message contains the version specifc pdu processing routines. Additional routines provide access to the security data, the security model specific constants etc..

See Also:
Serialized Form

Field Summary
static byte AUTH_NO_PRIV
          Used to specify that authenticated message be sent to the peer.
static byte AUTH_PRIV
          Used to specify that authentication and privacy are used in the communication with the peer.
static byte NO_AUTH_NO_PRIV
          Used to specify that both authentication and privacy should not be used.
static byte REPORT_FLAG
          Used to specify that the report flag is set when request is sent out.
 
Constructor Summary
Snmp3Message()
           
Snmp3Message(byte[] message)
          Creates an Snmp3Message object initialised with the given byte array.
Snmp3Message(byte[] message, SecurityProvider securityprovider)
          Creates an Snmp3Message object initialised with the given byte array and security provider.
 
Method Summary
 SnmpAPI getAPI()
           
 ASN1Parser getASNParser()
           
 byte getMsgFlags()
          Get the msgFlags field of the SNMP PDU.
 int getMsgID()
          Returns the message Id for the v3 packet.
 int getMsgMaxSize()
          Returns the max message size field of the SNMPV3 packet.
 SecurityModelEntry getSecurity()
          Get securityModel object is associated with the message.
 int getSecurityModel()
          Returns the securityModel assoicated with this message.
 SecurityProvider getSecurityProvider()
           
 boolean isAuthenticationFailed()
          Returns a boolean value based on whether V3 authentication has failed.
 void setMsgFlags(byte flags)
          This methods sets the message flags of the SNMPv3 message.
 void setMsgID(int id)
          Sets the message Id for the v3 packet
 void setMsgMaxSize(int size)
          Sets the message max size field for the SNMPV3 packet.
 void setSecurity(SecurityModelEntry entry, int modelNo)
          Set securityModel object is associated with the message.
 void setSecurityProvider(SecurityProvider provider)
           
 
Methods inherited from class com.adventnet.snmp.snmp2.SnmpMessage
getPDU, setMsgVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_AUTH_NO_PRIV

public static final byte NO_AUTH_NO_PRIV
Used to specify that both authentication and privacy should not be used.

AUTH_NO_PRIV

public static final byte AUTH_NO_PRIV
Used to specify that authenticated message be sent to the peer.

AUTH_PRIV

public static final byte AUTH_PRIV
Used to specify that authentication and privacy are used in the communication with the peer.

REPORT_FLAG

public static final byte REPORT_FLAG
Used to specify that the report flag is set when request is sent out.
Constructor Detail

Snmp3Message

public Snmp3Message()

Snmp3Message

public Snmp3Message(byte[] message,
                    SecurityProvider securityprovider)
             throws SnmpException
Creates an Snmp3Message object initialised with the given byte array and security provider. This byte array is the PDU data to be decoded. * This method is used only to decode the received PDU data.
Throws:
SnmpException - is thrown upon error.

Snmp3Message

public Snmp3Message(byte[] message)
             throws SnmpException
Creates an Snmp3Message object initialised with the given byte array. This byte array is the PDU data to be decoded. This method is used only to decode the received PDU data and the API user is not advised to use this method.
Throws:
SnmpException - is thrown whenever error occurs.
Method Detail

setMsgFlags

public void setMsgFlags(byte flags)
This methods sets the message flags of the SNMPv3 message. The "msgFlags" is an OCTET STRING of size one, as defined in the SNMPv3 message format. Of this one byte, only the least significant 3 bits are used.

The eight bits of this flag can be explained as follows:
 
 
NU NU NU NU NU R P A

NU - NOT USED
R     - Report bit. That is, if this bit is set to one, then the SNMPv3 entity that receives this message should respond back to the sender.
P     - Priv bit. That is, if this bit is set to one, then this SNMPv3 message uses privacy.
A     - Auth bit. That is, if this bit is set to one, then this SNMPv3 message uses authentication.

The Possible values for this msgFlags are
 
 
Value in Decimal R P A
0  0  0  0
1  0  0  1
3  0  1  1
4  1  0  0
5  1  0  1
7  1  1  1

There cannot be privacy without authentication, hence the values 2 and 6 cannot exist.
 
 
 

Parameters:
flags - the msgFlags value to set for this SNMPv3 message. If an invalid value is passed as argument to this method, then the method will return and the previous value will be retained.

getMsgFlags

public byte getMsgFlags()
Get the msgFlags field of the SNMP PDU.
Returns:
the messages flags field in the SNMPV3 message.

setMsgID

public void setMsgID(int id)
Sets the message Id for the v3 packet
Parameters:
id - The messageID to be set for the SNMPV3 request.

getMsgID

public int getMsgID()
Returns the message Id for the v3 packet.
Returns:
The messageID of the V3 packet to be sent or received.

setMsgMaxSize

public void setMsgMaxSize(int size)
Sets the message max size field for the SNMPV3 packet.
Parameters:
size - The maximum message size for the SNMPV3 packet.

getMsgMaxSize

public int getMsgMaxSize()
Returns the max message size field of the SNMPV3 packet.
Returns:
The maximum message size of the SNMPV3 packet.

getSecurity

public SecurityModelEntry getSecurity()
Get securityModel object is associated with the message.
Returns:
The securityModel reference maintained by this object.

setSecurity

public void setSecurity(SecurityModelEntry entry,
                        int modelNo)
Set securityModel object is associated with the message. The Snmp3Message creates a new securitymodel for decoding and encoding. This method sets the securitymodel reference
Parameters:
entry - The security model reference is to set the corresponding entry in the message.
modelNo - The securityModel no. is associated with the securit entry

getSecurityModel

public int getSecurityModel()
Returns the securityModel assoicated with this message.

setSecurityProvider

public void setSecurityProvider(SecurityProvider provider)

getSecurityProvider

public SecurityProvider getSecurityProvider()

getASNParser

public ASN1Parser getASNParser()

getAPI

public SnmpAPI getAPI()

isAuthenticationFailed

public boolean isAuthenticationFailed()
Returns a boolean value based on whether V3 authentication has failed. If the received SnmpV3 message fails in the authentication module which can be due to wrong digest or timeliness failure, then a flag is set to true. This method returns the status of the flag and is useful in the authenticate/callback method when the SnmpClient interface is implemented.
Returns:
True If the received SnmpV3 message fails in the authentication module, which can be due to wrong message digest or timeliness failure. Returns False otherwise.


Copyright (c)AdventNet Inc., 1996-2004