lecturequiz.server.main
Class UserManager

java.lang.Object
  extended by lecturequiz.server.main.UserManager

public class UserManager
extends java.lang.Object


Method Summary
 User addUser(java.lang.String username, int role)
          Adds a user to the user-pool.
 void addUser(User user)
          Adds a user to the list of users
 User authenticateUser(java.lang.String username, java.lang.String password)
          Tries to authenticate the user with the
static UserManager getInstance()
          Returns the instance of the UserManager class, or creates a new on if it doesn't exist.
 boolean isUsernameAvailable(java.lang.String username)
          Checks if the supplied username is already in use by another logged in user.
 void removeUser(User user)
          Removes a user from the list of users and any games they are in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static UserManager getInstance()
Returns the instance of the UserManager class, or creates a new on if it doesn't exist.

Returns:
The UserManager instance;

isUsernameAvailable

public boolean isUsernameAvailable(java.lang.String username)
Checks if the supplied username is already in use by another logged in user.

Parameters:
username - The name to check availability for.
Returns:
True if the name is available, false if not.

addUser

public User addUser(java.lang.String username,
                    int role)
Adds a user to the user-pool.

Parameters:
username - The username of the user to be added.
role - The role of the user to be added.
Returns:
The User-object created.

addUser

public void addUser(User user)
Adds a user to the list of users

Parameters:
user - the user to add

removeUser

public void removeUser(User user)
Removes a user from the list of users and any games they are in

Parameters:
user - the user to remove

authenticateUser

public User authenticateUser(java.lang.String username,
                             java.lang.String password)
Tries to authenticate the user with the

Parameters:
username - Username to authenticate
password - Password
Returns:
A User object or null if authentication failed