org.sourcejammer.server.security
Class UserManager

java.lang.Object
  |
  +--org.sourcejammer.server.security.UserManager

public class UserManager
extends java.lang.Object

This class reads and writes to the user.xml file. It keeps a cache of User objects for each user of the system.


Nested Class Summary
private static class UserManager.XMLNodes
           
 
Field Summary
private static java.lang.String ANNON_USER_FULL_NAME
           
private  java.util.Hashtable mhshUsers
           
private static UserManager moInstance
           
private static java.lang.String USER_COUNTER_FILE_NAME
           
private static java.lang.String USER_XML_FILE_NAME
           
 
Constructor Summary
private UserManager()
           
 
Method Summary
 void addUser(java.lang.String userName, java.lang.String password, java.lang.String fullName, boolean isAdmin)
          Add a new user to the system using the username, password, and full name passed in.
 void changeUserPassword(User oUser, java.lang.String userName, java.lang.String newPassword)
          Change a user's password.
static UserManager getInstance()
           
 User getUserObject(java.lang.String userName)
          Returns user object with specified user name.
private  User getUserObject(java.lang.String userName, java.lang.String password)
          Returns user object with specified username.
 java.util.Enumeration getUsersList()
           
private  void loadUsers()
          Load the user.xml file and build a cache of user objects.
private  void loadUsersIfNull()
          Loads users from xml if user cache is null.
 User logInUser(java.lang.String userName, java.lang.String password)
          Logs in the specified users using the password.
 void modifyUser(java.lang.String userName, boolean isAdmin)
           
 void modifyUser(java.lang.String userName, java.lang.String newFullName)
           
 void removeUser(java.lang.String userName)
           
private  void saveUsers()
          Overwrite existing user.xml file with new XML build from users cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_XML_FILE_NAME

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

USER_COUNTER_FILE_NAME

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

mhshUsers

private java.util.Hashtable mhshUsers

ANNON_USER_FULL_NAME

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

moInstance

private static UserManager moInstance
Constructor Detail

UserManager

private UserManager()
Method Detail

getInstance

public static UserManager getInstance()

getUsersList

public java.util.Enumeration getUsersList()

modifyUser

public void modifyUser(java.lang.String userName,
                       java.lang.String newFullName)
                throws UserDoesNotExistException
UserDoesNotExistException

modifyUser

public void modifyUser(java.lang.String userName,
                       boolean isAdmin)
                throws UserDoesNotExistException
UserDoesNotExistException

logInUser

public User logInUser(java.lang.String userName,
                      java.lang.String password)
               throws InvalidPasswordException,
                      UserDoesNotExistException
Logs in the specified users using the password. Returns the User object.

InvalidPasswordException
UserDoesNotExistException

getUserObject

public User getUserObject(java.lang.String userName)
                   throws UserDoesNotExistException
Returns user object with specified user name. Does not validate password.

UserDoesNotExistException

getUserObject

private User getUserObject(java.lang.String userName,
                           java.lang.String password)
                    throws InvalidPasswordException,
                           UserDoesNotExistException
Returns user object with specified username. validates password.

InvalidPasswordException
UserDoesNotExistException

changeUserPassword

public void changeUserPassword(User oUser,
                               java.lang.String userName,
                               java.lang.String newPassword)
                        throws SecurityException,
                               UserDoesNotExistException
Change a user's password.

Parameters:
oUser - - the user object of the user requesting the change.
userName - - name of the user whose password is to be changed.
newPassword - - new password for userName.
SecurityException
UserDoesNotExistException

removeUser

public void removeUser(java.lang.String userName)
                throws UserDoesNotExistException
UserDoesNotExistException

addUser

public void addUser(java.lang.String userName,
                    java.lang.String password,
                    java.lang.String fullName,
                    boolean isAdmin)
             throws UserExistsException
Add a new user to the system using the username, password, and full name passed in.

UserExistsException

loadUsersIfNull

private void loadUsersIfNull()
                      throws java.io.IOException
Loads users from xml if user cache is null.

java.io.IOException

loadUsers

private void loadUsers()
                throws java.io.IOException
Load the user.xml file and build a cache of user objects.

java.io.IOException

saveUsers

private void saveUsers()
                throws java.io.IOException
Overwrite existing user.xml file with new XML build from users cache.

java.io.IOException


Copyright © 2003 Soucejammer project.