|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectLocalAcctMgr
Implements the AcctMgrSpec interface to provide basic account management
and persistence functions using local disk space.
This class authenticates a user against the CSH IMAP server.
User information is stored in a flat text file. When this class is
instantiated, the text file is read into a hashmap that is then used
to provide user information.
TODO: Surpress flushing to file right after change.
| Field Summary | |
(package private) ConfigMgr |
configMgr
Where the class gets its runtime configuration data from. |
private String |
filename
The file that stores the accounts data. |
private Hashtable |
hash
Stores the DrinkUser information. |
private static String |
hostname
The mail server we use to imap authenticate with. |
private DrinkLoggerSpec |
log
Our logger. |
private boolean |
performAuth
Whether or not to actually authenticate users. |
| Constructor Summary | |
LocalAcctMgr(DrinkLoggerSpec inLog,
ConfigMgr inConfig)
Saves the DrinkLogger variable and sets up the hashmap from the accounts text file. |
|
| Method Summary | |
boolean |
addUser(String username,
String password)
Adds a user to the system. |
boolean |
addUser(String username,
String password,
int balance,
boolean adminStatus)
Adds a user to the database of known users using the supplied values to initialize the account. |
boolean |
decreaseUserBalance(String username,
int amount)
Decrements a users balance. |
Vector |
dump()
Returns a vector of DrinkUser objects containing the data for every single last known user. |
int |
getUserBalance(String username)
Returns a users balance. |
boolean |
increaseUserBalance(String username,
int amount)
Increments a users balance. |
private boolean |
initialize()
TODO: Cleanup. |
boolean |
isSystemReady()
As specified in AcctMgrSpec, this returns whether or not the system is ready and available to process transactions. |
boolean |
isUserAdmin(String username)
Looks-up the admin status of a user. |
boolean |
isValidUser(String username)
Determines if the username is known to drink. |
boolean |
isValidUser(String username,
String password)
Validates a user against the CSH IMAP server. |
void |
purgeDatabase()
WARNING: USE WITH CAUTION. |
boolean |
removeUser(String username)
Removes a user from the hashmap and account file. |
private void |
saveConfig()
Saves the hashtable that stores all the user information to the accounts text file. |
boolean |
setUserAdmin(String username,
boolean admin)
Changes the admin status of a user. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private String filename
private static String hostname
private DrinkLoggerSpec log
private Hashtable hash
private boolean performAuth
ConfigMgr configMgr
| Constructor Detail |
public LocalAcctMgr(DrinkLoggerSpec inLog,
ConfigMgr inConfig)
inLog - The DrinkLogger to use when printing informationinConfig - The ConfigMgr to get our runtime configuration data from.| Method Detail |
private boolean initialize()
public boolean isValidUser(String username,
String password)
isValidUser in interface AcctMgrSpecusername - The user to authenticate.password - The users password.
public boolean isValidUser(String username)
isValidUser in interface AcctMgrSpecusername - The username to check.
public int getUserBalance(String username)
getUserBalance in interface AcctMgrSpecusername - The user whose balance is to be returned.
public boolean decreaseUserBalance(String username,
int amount)
decreaseUserBalance in interface AcctMgrSpecusername - The user whose account is to be decremented.amount - The amount to decrement the users account
AcctMgrSpec.increaseUserBalance(String, int)
public boolean increaseUserBalance(String username,
int amount)
increaseUserBalance in interface AcctMgrSpecusername - The username whose account is to be incremented.amount - The amount to increment the users account
AcctMgrSpec.decreaseUserBalance(String, int)
public boolean addUser(String username,
String password)
addUser in interface AcctMgrSpecusername - The username of the user to add to the systempassword - The users password to add to the system.
isValidUser(String,String)
public boolean addUser(String username,
String password,
int balance,
boolean adminStatus)
addUser in interface AcctMgrSpecusername - The username of the account to add.password - The password for the new account.balance - The accounts initial balance.adminStatus - Whether or not the new user is to be an admin.
public boolean removeUser(String username)
removeUser in interface AcctMgrSpecusername - The name of the user to remove
public boolean isUserAdmin(String username)
isUserAdmin in interface AcctMgrSpecusername - The name of the user to look-up
public boolean setUserAdmin(String username,
boolean admin)
setUserAdmin in interface AcctMgrSpecusername - The username to edit.admin - The admin status to set the user to.
public boolean isSystemReady()
isSystemReady in interface AcctMgrSpecpublic Vector dump()
dump in interface AcctMgrSpecpublic void purgeDatabase()
purgeDatabase in interface AcctMgrSpecprivate void saveConfig()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||