com.adventnet.snmp.snmp2.agent.usm
Class UsmUserTableRequestHandler

java.lang.Object
  extended by com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
      extended by com.adventnet.snmp.snmp2.agent.usm.UsmUserTableRequestHandler
All Implemented Interfaces:
VarBindRequestListener, AgentEventListener

public class UsmUserTableRequestHandler
extends SimpleRequestHandler

Handles all requests under usmUserTable group.


Field Summary
protected  SnmpAgent agentName
          The Reference for the Snmp Agent Instance.
static int[] USM_AES_PRIV_PROTOCOL
          Instance OID for the UsmAESPrivProtocol
static int[] USM_DES_PRIV_PROTOCOL
          Instance OID for the UsmDESPrivProtocol
static int[] USM_HMAC_MD5_PROTOCOL
          Instance OID for the UsmHMACMD5AuthProtocol
static int[] USM_HMAC_SHA_AUTH_PROTOCOL
          Instance OID for the UsmHMACSHAAuthProtocol
static int[] USM_NO_AUTH_PROTOCOL
          Instance OID for the UsmNoAuthProtocol
static int[] USM_NO_PRIV_PROTOCOL
          Instance OID for the UsmNoPrivProtocol
(package private) static int USMUSERAUTHKEYCHANGE
           
(package private) static int USMUSERAUTHPROTOCOL
           
(package private) static int USMUSERCLONEFROM
           
(package private) static int USMUSERENGINEID
           
(package private) static int USMUSERNAME
           
(package private) static int USMUSEROWNAUTHKEYCHANGE
           
(package private) static int USMUSEROWNPRIVKEYCHANGE
           
(package private) static int USMUSERPRIVKEYCHANGE
           
(package private) static int USMUSERPRIVPROTOCOL
           
(package private) static int USMUSERPUBLIC
           
(package private) static int USMUSERSECURITYNAME
           
(package private) static int USMUSERSTATUS
           
(package private) static int USMUSERSTORAGETYPE
           
 UsmUserTableXMLToVector xmlToVector
           
 
Fields inherited from class com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
instrumentHandler, listener, tableListener
 
Constructor Summary
UsmUserTableRequestHandler(SnmpAgent agentRef)
          Constructor for the UsmUserTableRequestHandler with agent Reference.
UsmUserTableRequestHandler(SnmpAgent agentRef, java.lang.String dirStr, java.lang.String fileName, java.lang.String format)
          Constructor for the UsmUserTableRequestHandler with agent Reference.
 
Method Summary
(package private)  boolean checkForRowStatus(USMUserEntry entry)
           
 boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName, byte[] eid, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, byte[] authKey, byte[] privKey, java.lang.Integer storageType, java.lang.Integer rowStatus)
           
 boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName, byte[] eid, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, java.lang.String authPassword, java.lang.String privPassword, java.lang.Integer storageType, java.lang.Integer rowStatus)
           
 boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, byte[] authKey, byte[] privKey, java.lang.Integer storageType, java.lang.Integer rowStatus)
          The Method to Create and Add a new USMUserEntry to USMUserTable.
 boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, java.lang.String authPassword, java.lang.String privPassword, java.lang.Integer storageType, java.lang.Integer rowStatus)
          The Method to Create and Add a new USMUserEntry to USMUserTable.
 USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName, byte[] eid, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, byte[] authKey, byte[] privKey, java.lang.Integer storageType, java.lang.Integer rowStatus)
           
 USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName, byte[] eid, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, java.lang.String authPassword, java.lang.String privPassword, java.lang.Integer storageType, java.lang.Integer rowStatus)
           
 USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, byte[] authKey, byte[] privKey, java.lang.Integer storageType, java.lang.Integer rowStatus)
          The Method to create a USMUserEntry.
 USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName, java.lang.Integer secLevel, java.lang.String usmUserCloneFrom, java.lang.Integer usmUserAuthProtocol, java.lang.Integer usmUserPrivProtocol, java.lang.String usmUserPublic, java.lang.String authPassword, java.lang.String privPassword, java.lang.Integer storageType, java.lang.Integer rowStatus)
          The Method to create a USMUserEntry.
(package private)  void createUsmUserEntry(USMUserEntry newEntry, int[] inst)
          Assigns the EngineID and UserName values for the newEntry from the instance (inst) received.Also, this method adds the newEntry to the USMUserTable and sorts the entries.
(package private)  void display()
          An utility method to print the contents of the vector containing the instances..May be moved to the utils package or removed as this is not going to be useful for API.
protected  SnmpAgent getAgentRef()
           
 int[] getOidRep()
          Retrives the integer representation of OID
protected  int[] getSubidList()
          Gets the subid list of the oid.
 java.util.Vector getTableVector()
          The method to return the Vector of USMUserEntries present in the USMUserTable.
static int[] getUsmUserTableOidRep()
          Getter for the Usm User Table Oid Representation.
protected  void processGetNextRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Process the GetNext Request message which is received from PduRequestHandler.
protected  void processGetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Handles the SNMP GET Requests..
protected  void processGetRequest(SnmpVarBind varb, int req, VarBindRequestEvent pe, USMUserEntry entry)
          Process the Get Request message for the given params.
protected  void processSetRequest(SnmpVarBind varb, AgentNode node, VarBindRequestEvent pe)
          Handles the SNMP SET requests...
 void serialize(java.io.ObjectOutputStream outMain)
          This method Serializes the Output Stream.
 void setAuthProtocol(USMUserEntry usmUserEntry, int[] authProtocol)
          Set the authProtocol value for this USMUserEntry.
 void setPrivProtocol(USMUserEntry usmUserEntry, int[] privProtocol)
          Set the privProtocol value for this USMUserEntry.
 void setTableVector(java.util.Vector usmVec)
          The method to set the Vector of USMUserEntries.
(package private)  boolean validateKeyLength(int protocol, int rcvdKeyLen)
          Validates the KeyLength value for the protocol.
 
Methods inherited from class com.adventnet.snmp.snmp2.agent.SimpleRequestHandler
addInstrumentHandler, addRegistrationListener, addTableListener, addUpdateListener, getInstrument, getMibVarHash, getNextRequest, getNextRequest, getObjectHash, getObjectTypeHash, getRequest, getTableListener, getUpdateListener, isWriteEachTime, processGetNextRequest, processGetRequest, processSetRequest, removeRegistrationListener, removeUpdateListener, setRequest, setWriteEachTime, writeIntoFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USMUSERENGINEID

static final int USMUSERENGINEID
See Also:
Constant Field Values

USMUSERNAME

static final int USMUSERNAME
See Also:
Constant Field Values

USMUSERSECURITYNAME

static final int USMUSERSECURITYNAME
See Also:
Constant Field Values

USMUSERCLONEFROM

static final int USMUSERCLONEFROM
See Also:
Constant Field Values

USMUSERAUTHPROTOCOL

static final int USMUSERAUTHPROTOCOL
See Also:
Constant Field Values

USMUSERAUTHKEYCHANGE

static final int USMUSERAUTHKEYCHANGE
See Also:
Constant Field Values

USMUSEROWNAUTHKEYCHANGE

static final int USMUSEROWNAUTHKEYCHANGE
See Also:
Constant Field Values

USMUSERPRIVPROTOCOL

static final int USMUSERPRIVPROTOCOL
See Also:
Constant Field Values

USMUSERPRIVKEYCHANGE

static final int USMUSERPRIVKEYCHANGE
See Also:
Constant Field Values

USMUSEROWNPRIVKEYCHANGE

static final int USMUSEROWNPRIVKEYCHANGE
See Also:
Constant Field Values

USMUSERPUBLIC

static final int USMUSERPUBLIC
See Also:
Constant Field Values

USMUSERSTORAGETYPE

static final int USMUSERSTORAGETYPE
See Also:
Constant Field Values

USMUSERSTATUS

static final int USMUSERSTATUS
See Also:
Constant Field Values

USM_NO_AUTH_PROTOCOL

public static final int[] USM_NO_AUTH_PROTOCOL
Instance OID for the UsmNoAuthProtocol


USM_HMAC_MD5_PROTOCOL

public static final int[] USM_HMAC_MD5_PROTOCOL
Instance OID for the UsmHMACMD5AuthProtocol


USM_HMAC_SHA_AUTH_PROTOCOL

public static final int[] USM_HMAC_SHA_AUTH_PROTOCOL
Instance OID for the UsmHMACSHAAuthProtocol


USM_NO_PRIV_PROTOCOL

public static final int[] USM_NO_PRIV_PROTOCOL
Instance OID for the UsmNoPrivProtocol


USM_DES_PRIV_PROTOCOL

public static final int[] USM_DES_PRIV_PROTOCOL
Instance OID for the UsmDESPrivProtocol


USM_AES_PRIV_PROTOCOL

public static final int[] USM_AES_PRIV_PROTOCOL
Instance OID for the UsmAESPrivProtocol


agentName

protected SnmpAgent agentName
The Reference for the Snmp Agent Instance.


xmlToVector

public UsmUserTableXMLToVector xmlToVector
Constructor Detail

UsmUserTableRequestHandler

public UsmUserTableRequestHandler(SnmpAgent agentRef)
Constructor for the UsmUserTableRequestHandler with agent Reference.

Parameters:
agentRef - The Reference for the Snmp Agent.

UsmUserTableRequestHandler

public UsmUserTableRequestHandler(SnmpAgent agentRef,
                                  java.lang.String dirStr,
                                  java.lang.String fileName,
                                  java.lang.String format)
Constructor for the UsmUserTableRequestHandler with agent Reference.

Parameters:
agentRef - The Agent Reference.
dirStr - the directory location String of the File.
fileName - The fileName String.
format - The file format("xml").
Method Detail

getUsmUserTableOidRep

public static int[] getUsmUserTableOidRep()
Getter for the Usm User Table Oid Representation.

Returns:
The Usm User Table Oid Value.

getOidRep

public int[] getOidRep()
Description copied from class: SimpleRequestHandler
Retrives the integer representation of OID

Overrides:
getOidRep in class SimpleRequestHandler
Returns:
the integer array of OID

getAgentRef

protected SnmpAgent getAgentRef()

getSubidList

protected int[] getSubidList()
Description copied from class: SimpleRequestHandler
Gets the subid list of the oid.

Overrides:
getSubidList in class SimpleRequestHandler
Returns:
the integer array of subid list

display

void display()
An utility method to print the contents of the vector containing the instances..May be moved to the utils package or removed as this is not going to be useful for API.


setAuthProtocol

public void setAuthProtocol(USMUserEntry usmUserEntry,
                            int[] authProtocol)
                     throws AgentSnmpException
Set the authProtocol value for this USMUserEntry.

Parameters:
usmUserEntry - the USMUserEntry for which the authProtocol is to be set
authProtocol - the instanceOID to be converted to equivalent authProtocol value for this USMUserEntry
Throws:
AgentRuntimeException - if the authProtocol doesn't belong to the constants defined.
AgentSnmpException

setPrivProtocol

public void setPrivProtocol(USMUserEntry usmUserEntry,
                            int[] privProtocol)
                     throws AgentSnmpException
Set the privProtocol value for this USMUserEntry.

Parameters:
usmUserEntry - the USMUserEntry for which the privProtocol is to be set
privProtocol - the instanceOID to be converted to equivalent privProtocol value for this USMUserEntry
Throws:
AgentRuntimeException - if the privProtocol doesn't belong to the constants defined.
AgentSnmpException

processGetRequest

protected void processGetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Handles the SNMP GET Requests..

Overrides:
processGetRequest in class SimpleRequestHandler
Parameters:
varb - The received varbind .
node - The node for which Get Request is to be done.
pe - The VarBind Request Event created by this Get request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

processGetRequest

protected void processGetRequest(SnmpVarBind varb,
                                 int req,
                                 VarBindRequestEvent pe,
                                 USMUserEntry entry)
                          throws AgentSnmpException
Process the Get Request message for the given params.

Parameters:
varb - The received VarBind.
req - The request given.
pe - The Varbind Request Event created after thid Event.
entry - The Usm User Entry for the Request.
Throws:
This - wraps all the Exceptions thrown by the Agent while Processing this event.
AgentSnmpException

processSetRequest

protected void processSetRequest(SnmpVarBind varb,
                                 AgentNode node,
                                 VarBindRequestEvent pe)
                          throws AgentSnmpException
Handles the SNMP SET requests...

Overrides:
processSetRequest in class SimpleRequestHandler
Parameters:
varb - The received varbind.
node - The node for which Get Next Request is to be done.
pe - The VarBind Request Event created by this GetNext request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

processGetNextRequest

protected void processGetNextRequest(SnmpVarBind varb,
                                     AgentNode node,
                                     VarBindRequestEvent pe)
                              throws AgentSnmpException
Description copied from class: SimpleRequestHandler
Process the GetNext Request message which is received from PduRequestHandler.

Overrides:
processGetNextRequest in class SimpleRequestHandler
Parameters:
varb - The received varbind.
node - The node for which Get Next Request is to be done.
pe - The VarBind Request Event created by this GetNext request.
Throws:
AgentSnmpException - This wraps all the Exceptions thrown while Processing the Event.

validateKeyLength

boolean validateKeyLength(int protocol,
                          int rcvdKeyLen)
Validates the KeyLength value for the protocol.

Parameters:
protocol - the protocol value.
rcvdKeyLen - the key Length value.
Returns:
boolean true if the rcvdKeyLen is the correct keyLength for the protocol, false otherwise.

createUsmUserEntry

void createUsmUserEntry(USMUserEntry newEntry,
                        int[] inst)
Assigns the EngineID and UserName values for the newEntry from the instance (inst) received.Also, this method adds the newEntry to the USMUserTable and sorts the entries.

Parameters:
newEntry - the USMUserEntry to be added to the USMUserTable.
inst - the instance OID from which the EngineID and userName is to be decoded.

checkForRowStatus

boolean checkForRowStatus(USMUserEntry entry)
                    throws AgentSnmpException
Throws:
AgentSnmpException

serialize

public void serialize(java.io.ObjectOutputStream outMain)
This method Serializes the Output Stream.

Parameters:
outMain - The objet Output stream to be serialized.

getTableVector

public java.util.Vector getTableVector()
The method to return the Vector of USMUserEntries present in the USMUserTable.

Returns:
The Vector of USMUserEntries.

setTableVector

public void setTableVector(java.util.Vector usmVec)
The method to set the Vector of USMUserEntries.

Parameters:
The - Vector of USMUserEntries.

createAndAddUSMUserEntry

public boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName,
                                        java.lang.Integer secLevel,
                                        java.lang.String usmUserCloneFrom,
                                        java.lang.Integer usmUserAuthProtocol,
                                        java.lang.Integer usmUserPrivProtocol,
                                        java.lang.String usmUserPublic,
                                        java.lang.String authPassword,
                                        java.lang.String privPassword,
                                        java.lang.Integer storageType,
                                        java.lang.Integer rowStatus)
The Method to Create and Add a new USMUserEntry to USMUserTable.

Parameters:
usmUserSecurityName - The contextPrefix with which the entry is to be created.
securityModel - The securityModel with which the entry is to be created(Default - USM (3)).
secLevel - The securityLevel with which the entry is to be created.
usmUserCloneFrom - The usmUserCloneFrom with which the entry is to be created(Default .0.0)
usmUserAuthProtocol - The usmUserAuthProtocol for this User.
usmUserPrivProtocol - The usmUserPrivProtocol for this User.
authPassword - The authPassword for this User.
privPassword - The privPassword for this User.
usmUserPublic - The usmUserPublic for this entry.
storageType - The storageType for the Entry.
rowStatus - The RowStatus Integer for the Entry.
Returns:
The boolean specifying whether the row is added Successfylly or Not.
See Also:
createUsmUserEntry

createAndAddUSMUserEntry

public boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName,
                                        byte[] eid,
                                        java.lang.Integer secLevel,
                                        java.lang.String usmUserCloneFrom,
                                        java.lang.Integer usmUserAuthProtocol,
                                        java.lang.Integer usmUserPrivProtocol,
                                        java.lang.String usmUserPublic,
                                        java.lang.String authPassword,
                                        java.lang.String privPassword,
                                        java.lang.Integer storageType,
                                        java.lang.Integer rowStatus)

createAndAddUSMUserEntry

public boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName,
                                        java.lang.Integer secLevel,
                                        java.lang.String usmUserCloneFrom,
                                        java.lang.Integer usmUserAuthProtocol,
                                        java.lang.Integer usmUserPrivProtocol,
                                        java.lang.String usmUserPublic,
                                        byte[] authKey,
                                        byte[] privKey,
                                        java.lang.Integer storageType,
                                        java.lang.Integer rowStatus)
The Method to Create and Add a new USMUserEntry to USMUserTable.

Parameters:
usmUserSecurityName - The contextPrefix with which the entry is to be created.
securityModel - The securityModel with which the entry is to be created(Default - USM (3)).
secLevel - The securityLevel with which the entry is to be created.
usmUserCloneFrom - The usmUserCloneFrom with which the entry is to be created(Default .0.0)
usmUserAuthProtocol - The usmUserAuthProtocol for this User.
usmUserPrivProtocol - The usmUserPrivProtocol for this User.
authKey - The authKey used for this User.
privKey - The privKey used for this User.
usmUserPublic - The usmUserPublic for this entry.
storageType - The storageType for the Entry.
rowStatus - The RowStatus Integer for the Entry.
Returns:
The boolean specifying whether the row is added Successfylly or Not.
See Also:
createUsmUserEntry

createAndAddUSMUserEntry

public boolean createAndAddUSMUserEntry(java.lang.String usmUserSecurityName,
                                        byte[] eid,
                                        java.lang.Integer secLevel,
                                        java.lang.String usmUserCloneFrom,
                                        java.lang.Integer usmUserAuthProtocol,
                                        java.lang.Integer usmUserPrivProtocol,
                                        java.lang.String usmUserPublic,
                                        byte[] authKey,
                                        byte[] privKey,
                                        java.lang.Integer storageType,
                                        java.lang.Integer rowStatus)

createUsmUserEntry

public USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName,
                                       java.lang.Integer secLevel,
                                       java.lang.String usmUserCloneFrom,
                                       java.lang.Integer usmUserAuthProtocol,
                                       java.lang.Integer usmUserPrivProtocol,
                                       java.lang.String usmUserPublic,
                                       java.lang.String authPassword,
                                       java.lang.String privPassword,
                                       java.lang.Integer storageType,
                                       java.lang.Integer rowStatus)
The Method to create a USMUserEntry.

Parameters:
usmUserSecurityName - The contextPrefix with which the entry is to be created.
securityModel - The securityModel with which the entry is to be created(Default - USM (3)).
secLevel - The securityLevel with which the entry is to be created.
usmUserCloneFrom - The usmUserCloneFrom with which the entry is to be created(Default .0.0)
usmUserAuthProtocol - The usmUserAuthProtocol for this User.
usmUserPrivProtocol - The usmUserPrivProtocol for this User.
authPassword - The authPassword for this User.
privPassword - The privPassword for this User.
usmUserPublic - The usmUserPublic for this entry.
storageType - The storageType for the Entry.
rowStatus - The RowStatus Integer for the Entry.
Returns:
The created USMUserEntry Object.
See Also:
createAndAddUSMUserEntry

createUsmUserEntry

public USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName,
                                       byte[] eid,
                                       java.lang.Integer secLevel,
                                       java.lang.String usmUserCloneFrom,
                                       java.lang.Integer usmUserAuthProtocol,
                                       java.lang.Integer usmUserPrivProtocol,
                                       java.lang.String usmUserPublic,
                                       java.lang.String authPassword,
                                       java.lang.String privPassword,
                                       java.lang.Integer storageType,
                                       java.lang.Integer rowStatus)

createUsmUserEntry

public USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName,
                                       java.lang.Integer secLevel,
                                       java.lang.String usmUserCloneFrom,
                                       java.lang.Integer usmUserAuthProtocol,
                                       java.lang.Integer usmUserPrivProtocol,
                                       java.lang.String usmUserPublic,
                                       byte[] authKey,
                                       byte[] privKey,
                                       java.lang.Integer storageType,
                                       java.lang.Integer rowStatus)
The Method to create a USMUserEntry.

Parameters:
usmUserSecurityName - The contextPrefix with which the entry is to be created.
securityModel - The securityModel with which the entry is to be created(Default - USM (3)).
secLevel - The securityLevel with which the entry is to be created.
usmUserCloneFrom - The usmUserCloneFrom with which the entry is to be created(Default .0.0)
usmUserAuthProtocol - The usmUserAuthProtocol for this User.
usmUserPrivProtocol - The usmUserPrivProtocol for this User.
authKey - The authKey used for this User.
privKey - The privKey used for this User.
usmUserPublic - The usmUserPublic for this entry.
storageType - The storageType for the Entry.
rowStatus - The RowStatus Integer for the Entry.
Returns:
The created USMUserEntry Object.
See Also:
createAndAddUSMUserEntry

createUsmUserEntry

public USMUserEntry createUsmUserEntry(java.lang.String usmUserSecurityName,
                                       byte[] eid,
                                       java.lang.Integer secLevel,
                                       java.lang.String usmUserCloneFrom,
                                       java.lang.Integer usmUserAuthProtocol,
                                       java.lang.Integer usmUserPrivProtocol,
                                       java.lang.String usmUserPublic,
                                       byte[] authKey,
                                       byte[] privKey,
                                       java.lang.Integer storageType,
                                       java.lang.Integer rowStatus)