Class AccountManager

  • All Implemented Interfaces:
    CommonManager

    public final class AccountManager
    extends AbstractManager
    This class is responsible to manage system accounts: add, remove and modify.
    • 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 account
        adminCredential - the credentials of the admin account
        newaccount - 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 account
        adminCredential - 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 validated
        credential - the credential of the account
        role - 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 validated
        credential - 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.