|
Project 3 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcscie259.project3.wahoo.UserManager
This class keeps track of users of the Wahoo portal by writing out information to an xml file. You MAY modify this file.
Nested Class Summary | |
private class |
UserManager.UserReader
An inner class which is the SAX2 handler used to read the user XML file into Java objects. |
Field Summary | |
private javax.servlet.ServletContext |
context_
a reference to the servlet context |
private static UserManager |
instance_
a reference to the one and only instance of this class |
private java.util.Map |
users_
a hash table of all users |
Constructor Summary | |
private |
UserManager(javax.servlet.ServletContext context)
A constructor that reads the user DB from an input stream. |
Method Summary | |
static User |
addUser(java.lang.String username,
java.lang.String password)
Adds a new user using the given username and password. |
private User |
addUserImpl(java.lang.String username,
java.lang.String password)
Adds a new user using the supplied username and password. |
static User |
getUser(java.lang.String username)
Returns a User object for given username or null if one is not found. |
private User |
getUserImpl(java.lang.String username)
Returns a User object for given username or null if one is not found. |
static void |
init(javax.servlet.ServletContext context)
Must be called (e.g., by Login's init() method) once before using any other method in class. |
private static UserManager |
instance()
Returns the one and only instance of this class, throwing an exception if it has not been initialized. |
private void |
readUsers(java.io.InputStream in)
Read the user info from the input stream. |
static void |
save()
Saves the information about all users to the information database (stored as a file). |
private void |
writeUsers()
Writes users info to the config file, overwriting old contents. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private javax.servlet.ServletContext context_
private static UserManager instance_
private java.util.Map users_
Constructor Detail |
private UserManager(javax.servlet.ServletContext context)
Method Detail |
public static User addUser(java.lang.String username, java.lang.String password)
username
- user's usernamepassword
- user's password
private User addUserImpl(java.lang.String username, java.lang.String password)
username
- user's usernamepassword
- user's password
public static User getUser(java.lang.String username)
username
- user's username
private User getUserImpl(java.lang.String username)
username
- user's username
public static void init(javax.servlet.ServletContext context)
context
- servlet's context objectprivate static UserManager instance()
private void readUsers(java.io.InputStream in)
in
- input streampublic static void save()
private void writeUsers()
|
Project 3 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |