com.limegroup.gnutella.security
Class UserManager

java.lang.Object
  extended bycom.limegroup.gnutella.security.UserManager

public class UserManager
extends java.lang.Object

Manages the user authentication data Note: Implements Singleton Design Pattern Note: The methods in this class are synchronized, as different processes may be accessing same instance. And so the process using this class doesnt have enough information to figure out when to synchronize.


Method Summary
 java.lang.String[] getAllUsers()
          Returns all the users
 User getUser(java.lang.String username)
          Returns the user data corresponding to the given username
static UserManager instance()
          Returns an instance of UserManager Note: Implements Singleton Design Pattern
static void main(java.lang.String[] args)
           
 void putUser(User user)
          Adds the passed user to the list of users.
 void removeUser(java.lang.String username)
          Removes the user data corresponding to the given username
 void save()
          Saves the user map to file
 java.lang.String toString()
          returns the string representation of the contents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

instance

public static UserManager instance()
Returns an instance of UserManager Note: Implements Singleton Design Pattern


getUser

public User getUser(java.lang.String username)
Returns the user data corresponding to the given username

Parameters:
username - Unique name identifying the user, whose information is requested.
Returns:
The user data corresponding to the given username. Returns null if no data exists for the given user (i.e. UserManager doesnt know about this user)

putUser

public void putUser(User user)
Adds the passed user to the list of users. If a user exists earlier with the same username as the passed user, its old information is replaced by the new data passed.

Parameters:
user - The user to be added

getAllUsers

public java.lang.String[] getAllUsers()
Returns all the users

Returns:
all the users.

removeUser

public void removeUser(java.lang.String username)
Removes the user data corresponding to the given username

Parameters:
username - Unique name identifying the user, who has to be deleted.

save

public void save()
Saves the user map to file


toString

public java.lang.String toString()
returns the string representation of the contents

Returns:
the string representation of the contents

main

public static void main(java.lang.String[] args)