|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectNetAcctClient
This class is the client to the networked account server (NetAcctServer). It implements the AcctMgrSpec interface so that it can act as a drop-in AcctMgrSpec, and connects to the account server to retrieve its information. TODO: Change protocol to be like sunday protocol. TODO: Add support for purge db/geteverything.
| Nested Class Summary | |
private class |
NetAcctClient.ConnectionMgr
Basically, this class keeps track of the connection to the NetAcctServer and trys to ensure that it is always connected. |
| Field Summary | |
private ConfigMgr |
configMgr
Where we get our runtime configuration management data from. |
private Socket |
connection
The connection to the server. |
private NetAcctClient.ConnectionMgr |
connMgr
The class responsible for maintaining the connection between this class and the server. |
private BufferedReader |
in
The BufferedReader that wraps around the input stream from the socket. |
private DrinkLoggerSpec |
log
Where we send all of our log messages. |
private PrintWriter |
out
The PrintWriter that wraps around the output stream for the socket. |
private String |
passFile
The file that stores the password that the CLIENT uses to authenticate to the server. |
private boolean |
performAuth
Whether or not to actually care about authentication. |
private String |
remoteHost
The IP/hostname of the host we are connected to. |
private int |
remotePort
The port we are connected to. |
| Constructor Summary | |
NetAcctClient(DrinkLoggerSpec inLog,
ConfigMgr inConfigMgr)
Construct a new NetAcctClient to connect to the specified NetAcctServer on the specified port. |
|
| Method Summary | |
boolean |
addUser(String username,
String password)
Adds a user to the database of known users. |
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. |
private boolean |
authenticate()
A simple helper method to perform the initial authentication. |
boolean |
decreaseUserBalance(String username,
int amount)
Decrements a users balance by the specified amount. |
Vector |
dump()
TODO: Implement this.... |
int |
getUserBalance(String username)
Retrieves the credit balance on a users account. |
boolean |
increaseUserBalance(String username,
int amount)
Increases a users balance. |
boolean |
isSystemReady()
Verifies that the connection to the server is ready and working. |
boolean |
isUserAdmin(String username)
Checks to see if a user is an admin. |
boolean |
isValidUser(String username)
Determines if a user is known to the system. |
boolean |
isValidUser(String username,
String password)
Authenticates a user. |
void |
purgeDatabase()
TODO: Implement this... |
String |
queryServer(String message)
This method sends the server the message and waits for a response. |
String |
queryServer(String header,
String message)
Sends a message to the server and returns the response. |
boolean |
removeUser(String username)
Removes a user from the database of known users. |
boolean |
setUserAdmin(String username,
boolean admin)
Changes the user's admin status. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private int remotePort
private String remoteHost
private DrinkLoggerSpec log
private String passFile
private boolean performAuth
private Socket connection
private PrintWriter out
private BufferedReader in
private NetAcctClient.ConnectionMgr connMgr
private ConfigMgr configMgr
| Constructor Detail |
public NetAcctClient(DrinkLoggerSpec inLog,
ConfigMgr inConfigMgr)
inLog - The DrinkLoggerSpec to print messages to.
//@param inHost The server to connect to.
//@param inPort The port on the server to connect to.
//@param inPassFile The file that contains this NetAcctClient's password file.inConfigMgr - Where we get our runtime configuration data.| Method Detail |
private boolean authenticate()
public String queryServer(String message)
message - The message to send to the server
public String queryServer(String header,
String message)
header - The header or action to be sent to the server.message - The message or data to be sent to the server.
queryServer(String)public int getUserBalance(String username)
getUserBalance in interface AcctMgrSpecusername - The username of the user to retrieve the balance for.
public boolean isUserAdmin(String username)
isUserAdmin in interface AcctMgrSpecusername - The username of the account to query.
public boolean isValidUser(String username)
isValidUser in interface AcctMgrSpecusername - The username of the account to query
public boolean isValidUser(String username,
String password)
isValidUser in interface AcctMgrSpecusername - The username of the user.password - The user's password.
public boolean isSystemReady()
isSystemReady in interface AcctMgrSpecpublic Vector dump()
dump in interface AcctMgrSpecpublic void purgeDatabase()
purgeDatabase in interface AcctMgrSpec
public boolean decreaseUserBalance(String username,
int amount)
decreaseUserBalance in interface AcctMgrSpecusername - The username of the account to decrement.amount - The amount to decrement the users balance.
AcctMgrSpec.decreaseUserBalance(String, int),
LocalAcctMgr.decreaseUserBalance(String, int),
queryServer(String,String),
increaseUserBalance(String, int)
public boolean increaseUserBalance(String username,
int amount)
increaseUserBalance in interface AcctMgrSpecusername - The username of the account to credit.amount - The amount to increment the users account.
AcctMgrSpec.increaseUserBalance(String, int),
LocalAcctMgr.increaseUserBalance(String, int),
queryServer(String,String),
decreaseUserBalance(String, int)
public boolean addUser(String username,
String password)
addUser in interface AcctMgrSpecusername - The username of the user to addpassword - The password of the user.
AcctMgrSpec.addUser(String,String),
queryServer( 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 username of the user to remove.
public boolean setUserAdmin(String username,
boolean admin)
setUserAdmin in interface AcctMgrSpecusername - The user to editadmin - The new admin status of the user
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||