Interface AcctMgrSpec

All Known Implementing Classes:
DBLocalAcctMgr, LocalAcctMgr, NetAcctClient

public interface AcctMgrSpec

This class defines the interface for performing user management and authentication in the drink system. Currently, this class provides methods to retrieve the administrator status of the user and their balance.

Version:
$Revision: #7 $
Author:
Kevin Thompson [antiduh@csh.rit.edu], Sean M. Graham [grahams@csh.rit.edu]

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 users account.
 boolean decreaseUserBalance(String username, int amount)
          Decrements a user's balance by the given amount.
 Vector dump()
          This provides a dump of all the data for every user known to the system.
 int getUserBalance(String username)
          Determines the number of credits a user has.
 boolean increaseUserBalance(String username, int amount)
          Increases a user's balance by the given amount.
 boolean isSystemReady()
          Returns whether or not the AcctMgrSpec is ready to process transactions.
 boolean isUserAdmin(String username)
          Determines if a given user is an administrator of drink.
 boolean isValidUser(String username)
          Determines if a user is known to the Drink system.
 boolean isValidUser(String username, String password)
          Authenticates a user.
 void purgeDatabase()
          Tells the database to remove all information regarding users.
 boolean removeUser(String username)
          Removes a user from the database of known users.
 boolean setUserAdmin(String username, boolean admin)
          Sets the user's admin flag to the given value.
 

Method Detail

isSystemReady

public boolean isSystemReady()
Returns whether or not the AcctMgrSpec is ready to process transactions.

Returns:
True if the system is ready, false otherwise.

isValidUser

public boolean isValidUser(String username,
                           String password)
Authenticates a user.

Parameters:
username - The user to authenticate.
password - The users password.
Returns:
True if the username and password authenticate, false otherwise.

isValidUser

public boolean isValidUser(String username)
Determines if a user is known to the Drink system.

Parameters:
username - The user to verify
Returns:
true if the username is known to the Drink system.

getUserBalance

public int getUserBalance(String username)
Determines the number of credits a user has.

Parameters:
username - The username whose balance is desired
Returns:
The number of credits a user has on their account.

decreaseUserBalance

public boolean decreaseUserBalance(String username,
                                   int amount)
Decrements a user's balance by the given amount.

Parameters:
username - The user whose account is to be decremented
amount - The amount, in credits, to decrement the users account.
Returns:
True if the operation was successful, false otherwise.
See Also:
increaseUserBalance(String, int)

increaseUserBalance

public boolean increaseUserBalance(String username,
                                   int amount)
Increases a user's balance by the given amount.

Parameters:
username - The user whose account is to be incremented.
amount - The amount to increase the users account
Returns:
True if the operation was successful, false otherwise.
See Also:
decreaseUserBalance(String, int)

addUser

public boolean addUser(String username,
                       String password)
Adds a user to the database of known users. By default, the users balance is set to zero and their admin status is set to false.

In future versions of this class that support Drink-specific passwords, the users password authentication mechanism will be set to authenticate against the CSH server (mail), and their drink-specific password will be blank.

Parameters:
username - The name of the user to add.
password - The new users drink-specific password.
Returns:
True if the operation was successful, false otherwise.
See Also:
LocalAcctMgr.isValidUser(String,String)

addUser

public 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 users account. This is useful for doing batch updates or perhaps dumping/restoring.

TODO: Note: as of 7-Jul-2004, the password is not used.

Parameters:
username - The username of the account to create.
password - The drink-specific password
balance - The users new balance. Negative is allowed.
adminStatus - Whether or not the user is to be an admin.
Returns:
True if the account manager is able to add the user, false otherwise. Also, if the account already exists, the operation will fail.

purgeDatabase

public void purgeDatabase()
Tells the database to remove all information regarding users. This is useful when importing new data into the database. USE WITH CAUTION. MAKE SURE THE DATA HAS BEEN BACKED UP.


dump

public Vector dump()
This provides a dump of all the data for every user known to the system. This is useful for backing up/exporting the data. On specific example would be the DBPorter program, which uses the dump from one account manager to restore to another account manager.


removeUser

public boolean removeUser(String username)
Removes a user from the database of known users.

Parameters:
username - The user to remove
Returns:
True if the operation was successful, false otherwise

isUserAdmin

public boolean isUserAdmin(String username)
Determines if a given user is an administrator of drink.

Parameters:
username - The user to be verified
Returns:
True if the user is an administrator, false otherwise.

setUserAdmin

public boolean setUserAdmin(String username,
                            boolean admin)
Sets the user's admin flag to the given value.

Parameters:
username - The user to edit
admin - The value to set the flag to.
Returns:
True if the operation was successful, false otherwise.