com.adventnet.snmp.snmp2.usm
Class USMUserTable

java.lang.Object
  extended by com.adventnet.snmp.snmp2.SecurityModelTable
      extended by com.adventnet.snmp.snmp2.usm.USMUserTable
All Implemented Interfaces:
java.io.Serializable

public class USMUserTable
extends SecurityModelTable
implements java.io.Serializable

This class maintains a list of all USMUserEntry objects and provides methods to operate on the list. Methods are provided to add, retrieve, modify and remove USMUserEntry objects. The API user need not instantiate this class explicitly. He has to create this table from the security provider by using the method SecurityProvider.createTable(int model) where model is the security model number. The SecurityProvider has the method getTable to get this table reference. Once a new USMUserEntry object is created, it has to be added to the USMUserTable, using the add method provided.

This class also provides methods to serialize and deSerialize the list of USMUserEntry objects. The USMUserEntry objects are always serialized in the file UserEntry.ser. The serialization will not work in case of applets using the serialization methods. This will be fixed in the future release.

See Also:
USMUserEntry, SnmpAPI, Serialized Form

Field Summary
(package private)  boolean alwaysSyncDiscovery
           
(package private) static int AUTHKEY
           
(package private) static int AUTHPASSWORD
           
(package private) static int AUTHPROTOCOL
           
(package private)  boolean dBaseFlag
          Database flag for this SnmpAPI instance
(package private) static int DBKEY
           
(package private)  com.adventnet.utils.DatabaseOperations dbOps
           
(package private) static int ENGINEBOOTS
           
(package private) static int ENGINEID
           
(package private) static int ENGINENAME
           
(package private) static int ENGINETIME
           
(package private)  com.adventnet.utils.DatabaseTableParams engParams
           
(package private) static int HOST
           
(package private) static int LATESTRCVDENGTIME
           
(package private) static int LOCALTIME
           
(package private) static int PORT
           
(package private) static int PRIVKEY
           
(package private) static int PRIVPASSWORD
           
(package private) static int PRIVPROTOCOL
           
(package private) static int SECURITYLEVEL
           
(package private) static int SECURITYNAME
           
(package private) static java.lang.String serUserFileName
           
(package private) static int USERNAME
           
(package private)  java.util.Hashtable userTable
           
(package private)  com.adventnet.utils.DatabaseTableParams usmParams
           
(package private)  boolean v3ConfigFlag
           
 
Constructor Summary
USMUserTable()
           
 
Method Summary
 boolean addEntry(SecurityModelEntry entry)
          Adds the USMUserEntry object to the list of USMUserEntry objects maintained in this class.
(package private)  java.lang.String convertString(java.lang.String str)
           
 void deSerialize()
          DeSerializes the file "UserEnrty.ser", to get a list of USMUserEntry objects.
 void deSerialize(java.io.ObjectInputStream in)
          DeSerializes the USMUserEntry objects, from the particular input Stream to the list of USMUserEntry objects.
(package private) static byte[] getBytes(java.lang.String s)
           
(package private) static java.lang.String getByteString(byte[] array, int offset, int length)
           
 java.util.Vector getEntries(java.lang.String host, int port)
          Returns, the Vector containing list of USMUserEntry objects corresponding to a particular SnmpV3 entity.
 USMUserEntry getEntry(byte[] name, byte[] id)
          Returns the USMUserEntry corresponding to the username and engineID.
 SecurityModelEntry getEntry(java.lang.Object key)
          Returns, the SecurityModelEntry for the particular 'key' that is given as an argument.
 java.util.Enumeration getEnumeration()
          Returns an enumeration of all the USMUserEntry objects maintained in this class.
 java.util.Vector getHashTableEntry(java.lang.String host, int port)
          Returns, the Vector containing list of USMUserEntry objects corresponding to a particular SnmpV3 entity.
 boolean isAlwaysSyncDiscovery()
           
 boolean isV3DatabaseFlag()
          Gets the Database flag for this SnmpAPI instance.
 boolean modifyEntry(SecurityModelEntry entry)
          Modifies the corresponding USMUserEntry object in the list of USMUserEntry objects.
(package private)  byte[] modifySendBytes(byte[] bytes)
           
 void readFromDatabase()
          Gets a list of USMUserEntry objects and puts it in the hashtable.
 void removeAllEntries()
          Deletes all the USMUserEntry objects maintained in this class.
 boolean removeEntry(byte[] name, byte[] id)
          Deletes the USMUserEntry corresponding to the userName and engineID, from the list of USMUserEntry objects.
 boolean removeEntry(SecurityModelEntry entry)
          Deletes this particlar USMUserEntry object, from the list of USMUserEntry objects.
 void serialize()
          Stores the list of USMUSerEntry objects in the serialized file "UseEntry.ser"
 void serialize(java.io.ObjectOutputStream out)
          Serializes the list of USMUserEntry objects into particular output Stream specified.
 void setAlwaysSyncDiscovery(boolean flag)
           
protected  void setDBOperations(com.adventnet.utils.DatabaseOperations db)
          All the Database operations will be performed only through this instance.
 void setV3ConfigFlag(boolean configFlag)
          Sets the V3 configuration flag.
 void setV3DatabaseFlag(boolean dbFlag)
          Sets the Database flag.
(package private)  void updateEngineEntries(SnmpEngineEntry snmpEntry)
          Updates the USMUserEntry objects for the particular EngineID to relate to the new SnmpEngineEntry object.
 void writeToDatabase()
          Stores the list of USMUSerEntry objects in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBKEY

static final int DBKEY
See Also:
Constant Field Values

HOST

static final int HOST
See Also:
Constant Field Values

PORT

static final int PORT
See Also:
Constant Field Values

ENGINENAME

static final int ENGINENAME
See Also:
Constant Field Values

ENGINEID

static final int ENGINEID
See Also:
Constant Field Values

USERNAME

static final int USERNAME
See Also:
Constant Field Values

SECURITYLEVEL

static final int SECURITYLEVEL
See Also:
Constant Field Values

SECURITYNAME

static final int SECURITYNAME
See Also:
Constant Field Values

AUTHPROTOCOL

static final int AUTHPROTOCOL
See Also:
Constant Field Values

AUTHPASSWORD

static final int AUTHPASSWORD
See Also:
Constant Field Values

AUTHKEY

static final int AUTHKEY
See Also:
Constant Field Values

PRIVPROTOCOL

static final int PRIVPROTOCOL
See Also:
Constant Field Values

PRIVPASSWORD

static final int PRIVPASSWORD
See Also:
Constant Field Values

PRIVKEY

static final int PRIVKEY
See Also:
Constant Field Values

ENGINETIME

static final int ENGINETIME
See Also:
Constant Field Values

ENGINEBOOTS

static final int ENGINEBOOTS
See Also:
Constant Field Values

LATESTRCVDENGTIME

static final int LATESTRCVDENGTIME
See Also:
Constant Field Values

LOCALTIME

static final int LOCALTIME
See Also:
Constant Field Values

userTable

java.util.Hashtable userTable

serUserFileName

static final java.lang.String serUserFileName
See Also:
Constant Field Values

dbOps

com.adventnet.utils.DatabaseOperations dbOps

usmParams

com.adventnet.utils.DatabaseTableParams usmParams

engParams

com.adventnet.utils.DatabaseTableParams engParams

dBaseFlag

boolean dBaseFlag
Database flag for this SnmpAPI instance


v3ConfigFlag

boolean v3ConfigFlag

alwaysSyncDiscovery

boolean alwaysSyncDiscovery
Constructor Detail

USMUserTable

public USMUserTable()
Method Detail

setDBOperations

protected void setDBOperations(com.adventnet.utils.DatabaseOperations db)
All the Database operations will be performed only through this instance. By default, SnmpAPI sets this object and the api users need not set it explicitly.

Overrides:
setDBOperations in class SecurityModelTable
Parameters:
db - the instance of the implemented "DatabaseOperations" class. This is a dummy implemented method. API users who do database operations can overwrite this method.

getEnumeration

public java.util.Enumeration getEnumeration()
Returns an enumeration of all the USMUserEntry objects maintained in this class.

Specified by:
getEnumeration in class SecurityModelTable
Returns:
The enumeration of all the USMUserEntry objects maintained in this class.

removeAllEntries

public void removeAllEntries()
Deletes all the USMUserEntry objects maintained in this class. Thus the list which maintains the list of USMUserEntry objects will be null.


getHashTableEntry

public java.util.Vector getHashTableEntry(java.lang.String host,
                                          int port)
Returns, the Vector containing list of USMUserEntry objects corresponding to a particular SnmpV3 entity. Thus the vector will contain all the USMUserEntry objects for a particular host and port i.e for a particular SnmpEngineEntry. This method is useful in getting all the user entries for a particular host and port.

Parameters:
host - The hostName corresponding to the UserEntry created.
port - The port corresponding to the UserEntry created.
Returns:
A vector of USMUserEntry objects which were created for the specified host and port.

getEntries

public java.util.Vector getEntries(java.lang.String host,
                                   int port)
Returns, the Vector containing list of USMUserEntry objects corresponding to a particular SnmpV3 entity. Thus the vector will contain all the USMUserEntry objects for a particular host and port i.e for a particular SnmpEngineEntry. This method is useful in getting all the user entries for a particular host and port.

Parameters:
host - The hostName corresponding to the UserEntry created.
port - The port corresponding to the UserEntry created.
Returns:
A vector of USMUserEntry objects which were created for the specified host and port.
Since:
AdventNet SNMP API 4 SP2 ( Release 4.0.2 )

setV3DatabaseFlag

public void setV3DatabaseFlag(boolean dbFlag)
Sets the Database flag.

Overrides:
setV3DatabaseFlag in class SecurityModelTable
Parameters:
dbFlag - the database flag to be set on this SnmpAPI instance.

isV3DatabaseFlag

public boolean isV3DatabaseFlag()
Gets the Database flag for this SnmpAPI instance.


setV3ConfigFlag

public void setV3ConfigFlag(boolean configFlag)
Sets the V3 configuration flag. This flag should be set, when the user needs to use a configuration table, in the case of V3 database.

Overrides:
setV3ConfigFlag in class SecurityModelTable
Parameters:
configFlag - the boolean value to be set. By default this flag is false.

setAlwaysSyncDiscovery

public void setAlwaysSyncDiscovery(boolean flag)

isAlwaysSyncDiscovery

public boolean isAlwaysSyncDiscovery()

addEntry

public boolean addEntry(SecurityModelEntry entry)
Adds the USMUserEntry object to the list of USMUserEntry objects maintained in this class.

Specified by:
addEntry in class SecurityModelTable
Parameters:
entry - The USMUserEntry which needs to be added to the list of USMUserEntry objects.
Returns:
True if the USMUSerEntry was successfully added to the list of USMUserEntry objects.

modifyEntry

public boolean modifyEntry(SecurityModelEntry entry)
Modifies the corresponding USMUserEntry object in the list of USMUserEntry objects.

Specified by:
modifyEntry in class SecurityModelTable
Parameters:
entry - The USMUserEnrty that is to be modified.
Returns:
True, if the entry was successfully modified. False, otherwise.

getEntry

public SecurityModelEntry getEntry(java.lang.Object key)
Returns, the SecurityModelEntry for the particular 'key' that is given as an argument. Each entry in this table has an unique key. This key is a combination of username and engineID.

Specified by:
getEntry in class SecurityModelTable
Returns:
the SecurityModelEntry for the particular 'key'.

getEntry

public USMUserEntry getEntry(byte[] name,
                             byte[] id)
Returns the USMUserEntry corresponding to the username and engineID.

Returns:
the USMUserEntry.

removeEntry

public boolean removeEntry(byte[] name,
                           byte[] id)
Deletes the USMUserEntry corresponding to the userName and engineID, from the list of USMUserEntry objects.

Parameters:
name - The userName for which the USMUserEntry object is to be deleted.
id - The engineID for which the USMUserEntry object is to be deleted.

removeEntry

public boolean removeEntry(SecurityModelEntry entry)
Deletes this particlar USMUserEntry object, from the list of USMUserEntry objects.

Specified by:
removeEntry in class SecurityModelTable
Parameters:
entry - The USMUserEntry object that is to be deleted.

updateEngineEntries

void updateEngineEntries(SnmpEngineEntry snmpEntry)
Updates the USMUserEntry objects for the particular EngineID to relate to the new SnmpEngineEntry object.


serialize

public void serialize()
Stores the list of USMUSerEntry objects in the serialized file "UseEntry.ser"


deSerialize

public void deSerialize()
DeSerializes the file "UserEnrty.ser", to get a list of USMUserEntry objects.


serialize

public void serialize(java.io.ObjectOutputStream out)
Serializes the list of USMUserEntry objects into particular output Stream specified.

Specified by:
serialize in class SecurityModelTable
Parameters:
out - The ObjectOutputStream for serialization

deSerialize

public void deSerialize(java.io.ObjectInputStream in)
DeSerializes the USMUserEntry objects, from the particular input Stream to the list of USMUserEntry objects.

Specified by:
deSerialize in class SecurityModelTable
Parameters:
in - The ObjectInputStream for deSerialization

writeToDatabase

public void writeToDatabase()
Stores the list of USMUSerEntry objects in the database.


readFromDatabase

public void readFromDatabase()
                      throws java.sql.SQLException
Gets a list of USMUserEntry objects and puts it in the hashtable.

Throws:
java.sql.SQLException

modifySendBytes

byte[] modifySendBytes(byte[] bytes)

getBytes

static byte[] getBytes(java.lang.String s)

getByteString

static java.lang.String getByteString(byte[] array,
                                      int offset,
                                      int length)

convertString

java.lang.String convertString(java.lang.String str)