Package es.bsc.dataclay.logic.accountmgr
Class AccountManager
- java.lang.Object
-
- es.bsc.dataclay.util.management.AbstractManager
-
- es.bsc.dataclay.logic.accountmgr.AccountManager
-
- All Implemented Interfaces:
CommonManager
public final class AccountManager extends AbstractManager
This class is responsible to manage system accounts: add, remove and modify.
-
-
Field Summary
-
Fields inherited from class es.bsc.dataclay.util.management.AbstractManager
dataSource
-
-
Constructor Summary
Constructors Constructor Description AccountManager(SQLiteDataSource dataSource)
Instantiates an Account Manager that uses the Backend configuration provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanCaches()
Method that cleans the caches of the manager.boolean
existsAccount(AccountID accountID)
Method that checeks whether an account exists or notAccount
getAccount(AccountID id)
Get the the account with the id provided.AccountID
getAccountID(String name)
Get the ID of the account with the name provided.HashSet<AccountID>
getAccountList(AccountID adminAccountID, PasswordCredential adminCredential)
Retrieves the list of users registered in the systemAccountManagerDB
getDbHandler()
Method used for unit testing.AccountID
newAccount(AccountID adminAccountID, PasswordCredential adminCredential, Account newaccount)
Method that registers a new accountboolean
validateAccount(AccountID accountID, PasswordCredential credential)
Method that validates the provided account with the given credentialsboolean
validateAccount(AccountID accountID, PasswordCredential credential, AccountRole role)
Method that validates the provided account with the given credentials and considering also its role
-
-
-
Constructor Detail
-
AccountManager
public AccountManager(SQLiteDataSource dataSource)
Instantiates an Account Manager that uses the Backend configuration provided. (which backend to use, how to use it).- Parameters:
managerName
- Manager/service name.
-
-
Method Detail
-
newAccount
public AccountID newAccount(AccountID adminAccountID, PasswordCredential adminCredential, Account newaccount)
Method that registers a new account- Parameters:
adminAccountID
- an admin accountadminCredential
- the credentials of the admin accountnewaccount
- the info of the new account- Returns:
- New account ID
-
getAccountList
public HashSet<AccountID> getAccountList(AccountID adminAccountID, PasswordCredential adminCredential)
Retrieves the list of users registered in the system- Parameters:
adminAccountID
- an admin accountadminCredential
- the credentials of the admin account- Returns:
- The IDs of the users registered in the system
-
validateAccount
public boolean validateAccount(AccountID accountID, PasswordCredential credential, AccountRole role)
Method that validates the provided account with the given credentials and considering also its role- Parameters:
accountID
- the account id to be validatedcredential
- the credential of the accountrole
- the role this account has- Returns:
- true if the account exists and has the provided credentials and role, false otherwise.
-
validateAccount
public boolean validateAccount(AccountID accountID, PasswordCredential credential)
Method that validates the provided account with the given credentials- Parameters:
accountID
- the account id to be validatedcredential
- the credential of the account- Returns:
- true if the account exists and has the provided credentials, false otherwise.
-
getAccountID
public AccountID getAccountID(String name)
Get the ID of the account with the name provided.- Parameters:
name
- Name of the account- Returns:
- The ID of the account with the name provided
- Throws:
RemoteException
- if the Account does not exist
-
getAccount
public Account getAccount(AccountID id)
Get the the account with the id provided.- Parameters:
id
- ID of the account- Returns:
- The Account specification
-
existsAccount
public boolean existsAccount(AccountID accountID)
Method that checeks whether an account exists or not- Parameters:
accountID
- the account id to be checked- Returns:
- true if the provided account eixsts, false otherwise
-
getDbHandler
public AccountManagerDB getDbHandler()
Method used for unit testing.- Returns:
- The db handler reference of this manager.
-
cleanCaches
public void cleanCaches()
Description copied from interface:CommonManager
Method that cleans the caches of the manager. Used on testing.- Specified by:
cleanCaches
in interfaceCommonManager
- Specified by:
cleanCaches
in classAbstractManager
-
-