public class AccountController extends Object
Account
objects.
This class contains methods that wrap AccountDAO
to
manipulate Account
objects.
Constructor and Description |
---|
AccountController()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
AccountTransfer |
authenticate(AccountTransfer transfer)
Authenticate a user in the database.
|
protected Account |
authenticate(String login,
String password,
String ip)
Authenticate a user in the database.
|
Account |
createAdminAccount() |
AccountTransfer |
createNewAccount(AccountTransfer info,
boolean sendEmail)
Creates a new account using the parameters passed.
|
AccountTransfer |
getAccountBySessionKey(String sessionKey) |
long |
getAccountId(String email) |
Account |
getByEmail(String email)
Retrieve
Account by user id. |
void |
invalidate(String sessionKey)
De-authenticate the given sessionKey.
|
boolean |
isAdministrator(String userId)
Check in the database if an account is a moderator.
|
void |
removeMemberFromGroup(long id,
String email) |
boolean |
resetPassword(String targetEmail)
Reset a user's password
|
Account |
save(Account account)
Store
Account into the database. |
AccountTransfer |
updateAccount(String requester,
long userId,
AccountTransfer transfer) |
AccountTransfer |
updatePassword(String userId,
long id,
AccountTransfer transfer)
Updates the specified user account's password
|
public AccountTransfer updateAccount(String requester, long userId, AccountTransfer transfer)
requester
- userId
- transfer
- public boolean resetPassword(String targetEmail)
targetEmail
- email address of user account to be changedpublic AccountTransfer updatePassword(String userId, long id, AccountTransfer transfer) throws PermissionException
userId
- email of user making change. If it is not the same as the email associated with the
id
, then this account must have administrator privilegesid
- unique (db) identifier for user whose password is to be changed.transfer
- wrapper around new passwordPermissionException
- if the account associated with userId
and id
are not
the same but the userId
does not have administrative privilegespublic AccountTransfer createNewAccount(AccountTransfer info, boolean sendEmail)
info
- contains information needed to create accountsendEmail
- whether to send account information (including password by email)public Account createAdminAccount()
public Account getByEmail(String email)
Account
by user id.email
- unique identifier for account, typically emailAccount
public long getAccountId(String email)
email
- an account identifier (usually email)IllegalArgumentException
- for an invalid account identifierpublic AccountTransfer getAccountBySessionKey(String sessionKey)
sessionKey
- null
public Account save(Account account)
Account
into the database.account
- Account
that has been saved.public boolean isAdministrator(String userId)
userId
- unique account identifier for userprotected Account authenticate(String login, String password, String ip)
Using the IAuthentication
specified in the
settings file, authenticate the user, and return the sessionData
login
- password
- ip
- IP Address of the user.null
public AccountTransfer authenticate(AccountTransfer transfer)
Using the IAuthentication
specified in the
settings file, authenticate the user, and return the sessionData
transfer
- user information containing the email and password to be used for authentication
If the sessionId field is set, it may or may not be used as the user's session idAccountTransfer
public void invalidate(String sessionKey)
sessionKey
- unique session identifierpublic void removeMemberFromGroup(long id, String email)
id
- email
- Copyright © 2017. All rights reserved.