org.activemath.webapp.user.account
Class AccountManager

java.lang.Object
  extended by org.activemath.webapp.user.account.AccountManager

public class AccountManager
extends Object

Singleton to manage the accounts of ActiveMath's users.
It provides the methods needed to create, remove and tend the user's accounts. Delegates most of the work to UserStorage now.


Field Summary
static String CHARSET
           
static Logger log
           
 
Method Summary
 boolean accountExists(String userId)
          returns true if an account for the given userId exists, false otherwise.
 void changePassword(String userId, String newPassword)
          Changes the password for the given user to newPassword.
 boolean checkAuthentication(String userId, String password)
          Returns true if the authentication of the user succeded, false otherwise.
 boolean checkAuthentication(String userId, String password, boolean isHashed)
           
 boolean checkAuthenticationHashed(String userId, String password)
           
 void createAccount(String userId, String password)
          Creates an account with the given userId, if it is not already taken.
 void createAccountNoCheck(String userId, String password)
           
 void destroyAccount(String userId)
          Destroys the account of the user with the given userId.
 AccountInfo getAccountInfo(String userId)
          Get the AccountInfo for the given userId from persistence.
static AccountManager getInstance()
          Gets the instance of the AccountManager singleton.
 List<String> listAccounts()
          Returns a list of all registered userId's.
 List<String> listAccountsForGroup(String groupId)
          Returns a list af registered userIds belonging to the supplied groupId
 List<String> listAccountsMatching(String filterText)
          Returns a list af registered userIds matching filterText.
 List<String> listAccountsWithRole(String role)
          Returns a list af registered userIds matching role
 List<String> listGroupsForTutor(String userId)
          Returns a list of a tutor's groups.
 List<String> listZombieAccounts()
          Returns a list of all userId's that have accounts but no user data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final Logger log

CHARSET

public static final String CHARSET
See Also:
Constant Field Values
Method Detail

getInstance

public static AccountManager getInstance()
Gets the instance of the AccountManager singleton.

Returns:
the AccountManager instance

createAccount

public void createAccount(String userId,
                          String password)
                   throws UsernameTakenException
Creates an account with the given userId, if it is not already taken.

Parameters:
userId - the desired userId to create an account for
password - the password to assign to the new user
Throws:
UsernameTakenException - if the userId was already taken.

createAccountNoCheck

public void createAccountNoCheck(String userId,
                                 String password)
                          throws UsernameTakenException
Throws:
UsernameTakenException

destroyAccount

public void destroyAccount(String userId)
Destroys the account of the user with the given userId.

Parameters:
userId - The Id of the user account to be destroyed

getAccountInfo

public AccountInfo getAccountInfo(String userId)
Get the AccountInfo for the given userId from persistence.

Returns:
AccountInfo from persistence, or null.

accountExists

public boolean accountExists(String userId)
returns true if an account for the given userId exists, false otherwise.

Parameters:
userId - The user id to check
Returns:
true if such an account exists, false otherwise.

listAccounts

public List<String> listAccounts()
Returns a list of all registered userId's.

Returns:
A List of all known userId's

listZombieAccounts

public List<String> listZombieAccounts()
Returns a list of all userId's that have accounts but no user data

Returns:
A list of all userId's that have accounts but no user data

listAccountsForGroup

public List<String> listAccountsForGroup(String groupId)
Returns a list af registered userIds belonging to the supplied groupId


listAccountsMatching

public List<String> listAccountsMatching(String filterText)
Returns a list af registered userIds matching filterText. The resulting list may return duplicates (AMATH-1898).


listAccountsWithRole

public List<String> listAccountsWithRole(String role)
Returns a list af registered userIds matching role


listGroupsForTutor

public List<String> listGroupsForTutor(String userId)
Returns a list of a tutor's groups.


checkAuthentication

public boolean checkAuthentication(String userId,
                                   String password)
Returns true if the authentication of the user succeded, false otherwise. If user is authenticated by the old IdentDB, his account is migrated to this account manager.

Parameters:
userId - the userId to authenticate
password - the supplied password to check (plain text)
Returns:
true if authentication succeded, false otherwise.

checkAuthenticationHashed

public boolean checkAuthenticationHashed(String userId,
                                         String password)

checkAuthentication

public boolean checkAuthentication(String userId,
                                   String password,
                                   boolean isHashed)

changePassword

public void changePassword(String userId,
                           String newPassword)
                    throws AccountManagerException
Changes the password for the given user to newPassword. Returns true if the modification succeeded, false otherwise.

Parameters:
userId - The id of the user to update the pwd for
newPassword - The value of the new password
Throws:
AccountManagerException - If there was no such user.