org.sourcejammer.server.security
Class UserManager

java.lang.Object
  |
  +--org.sourcejammer.server.security.UserManager
All Implemented Interfaces:
UserManagerInf

public class UserManager
extends java.lang.Object
implements UserManagerInf

Title: $FileName: UserManager.java$

Version:
$VerNum: 5$
Author:
$AuthorName: Rob MacGrogan$

$Description: $
$KeyWordsOff: $

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 java.lang.String USER_COUNTER_FILE_NAME
           
private static java.lang.String USER_XML_FILE_NAME
           
 
Constructor Summary
(package 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.
 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 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
Constructor Detail

UserManager

UserManager()
Method Detail

getUsersList

public java.util.Enumeration getUsersList()
Specified by:
getUsersList in interface UserManagerInf

modifyUser

public void modifyUser(java.lang.String userName,
                       boolean isAdmin)
                throws UserDoesNotExistException
Specified by:
modifyUser in interface UserManagerInf
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.

Specified by:
logInUser in interface UserManagerInf
InvalidPasswordException
UserDoesNotExistException

getUserObject

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

Specified by:
getUserObject in interface UserManagerInf
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.

Specified by:
changeUserPassword in interface UserManagerInf
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
Specified by:
removeUser in interface UserManagerInf
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.

Specified by:
addUser in interface UserManagerInf
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.