com.asdf.server
Class AccountManager

java.lang.Object
  extended by com.asdf.server.AccountManager

public class AccountManager
extends java.lang.Object

Handles creating, deleting, modifying and accessing of accounts.


Constructor Summary
AccountManager()
           
 
Method Summary
 boolean changePassword(java.lang.String username, java.lang.String password, java.lang.String newPassword)
          Changes password of a given user, if the user performing this action is allowed to do so.
 AccountManagementResponse createAccount(ClientConnection conn, java.lang.String accountName, java.lang.String password, int type)
          Handles account creating requests.
 boolean deleteAccount(java.lang.String username, java.lang.String password)
          Deletes an account from database and memory.
 AuthenticationResponse logIn(ClientConnection conn, java.lang.String username, java.lang.String passwd)
          ConnectionInfo conn wants to log in with Account named account, using password passwd
 AuthenticationResponse logOut(ClientConnection conn)
          Logout method.
 void setBalanceChange(java.lang.String gameName, double amount, Account account)
          Change user credit balance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AccountManager

public AccountManager()
Method Detail

changePassword

public boolean changePassword(java.lang.String username,
                              java.lang.String password,
                              java.lang.String newPassword)
Changes password of a given user, if the user performing this action is allowed to do so.

Parameters:
username - Account name of the user whose password is to be changed.
password - Old password of this user.
newPassword - New password.
Returns:
Returns true on success, false otherwise.

deleteAccount

public boolean deleteAccount(java.lang.String username,
                             java.lang.String password)
Deletes an account from database and memory.

Parameters:
username - Account name to be deleted.
password - Password for the account, to check that this user is allowed to perform this action.
Returns:
returns true on successful deletion, false otherwise.

logIn

public AuthenticationResponse logIn(ClientConnection conn,
                                    java.lang.String username,
                                    java.lang.String passwd)
ConnectionInfo conn wants to log in with Account named account, using password passwd

Parameters:
conn - Specifies the client who is performing the action
username - The name of the account with which the user wishes to login
passwd - The password the user is sending to login

logOut

public AuthenticationResponse logOut(ClientConnection conn)
Logout method.

Parameters:
conn -

createAccount

public AccountManagementResponse createAccount(ClientConnection conn,
                                               java.lang.String accountName,
                                               java.lang.String password,
                                               int type)
Handles account creating requests.

Parameters:
conn - The client connection used by the user.
accountName - Account name that is requested for creation.
password - Password for the new account.
type - Type of the account.
Returns:
Response message to the attempt.

setBalanceChange

public void setBalanceChange(java.lang.String gameName,
                             double amount,
                             Account account)
Change user credit balance. Positive amount increases the balance by given amount and negative does the other way around.

Parameters:
amount - Difference in balance
account - Account on which to make the change