com.adventnet.snmp.snmp2.usm
Class USMUserTable

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SecurityModelTable
        |
        +--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

Constructor Summary
USMUserTable()
           
 
Method Summary
 boolean addEntry(SecurityModelEntry entry)
          Adds the USMUserEntry object to the list of USMUserEntry objects maintained in this class.
 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.
 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 isV3DatabaseFlag()
          Gets the Database flag for this SnmpAPI instance.
 boolean modifyEntry(SecurityModelEntry entry)
          Modifies the corresponding USMUserEntry object in the list of USMUserEntry objects.
 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.
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.
 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
 

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
Following copied from class: com.adventnet.snmp.snmp2.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.
Overrides:
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.

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.

addEntry

public boolean addEntry(SecurityModelEntry entry)
Adds the USMUserEntry object to the list of USMUserEntry objects maintained in this class.
Overrides:
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.
Overrides:
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.
Overrides:
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.
Overrides:
removeEntry in class SecurityModelTable
Parameters:
entry - The USMUserEntry object that is to be deleted.

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.
Overrides:
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.
Overrides:
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.


Copyright (c)AdventNet Inc., 1996-2004