Interface UserAccountDataAccessProvider

All Superinterfaces:
DataAccessProvider, IdentifiableResourceDataAccessProvider<AccountAttributes>

public interface UserAccountDataAccessProvider extends IdentifiableResourceDataAccessProvider<AccountAttributes>
  • Method Details

    • fromAttributes

      @Nullable default @Nullable AccountAttributes fromAttributes(@Nullable Iterable<Attribute> attributes)
      Specified by:
      fromAttributes in interface IdentifiableResourceDataAccessProvider<AccountAttributes>
    • getById

      Retrieve an AccountAttributes object by the ID.

      Implementation Note: The default implementation delegates to getByUserName(String), ie. it makes the assumption that the ID is the username. If that's not the case, this method must be overwritten as appropriate.

      Specified by:
      getById in interface IdentifiableResourceDataAccessProvider<AccountAttributes>
      Parameters:
      id - resource ID
      Returns:
      a populated AccountAttributes object or null if not found
    • getById

      @Nullable default @Nullable ResourceAttributes<?> getById(String id, ResourceQuery.AttributesEnumeration attributesEnumeration)
      Retrieve an AccountAttributes object by the ID.

      Implementation Note: The default implementation delegates to getByUserName(String), ie. it makes the assumption that the ID is the username. If that's not the case, this method must be overwritten as appropriate.

      Parameters:
      id - resource ID
      attributesEnumeration - attributes inclusions or exclusions
      Returns:
      a populated AccountAttributes object or null if not found
    • getByUserName

      @Nullable default @Nullable AccountAttributes getByUserName(String userName)
      Retrieve an AccountAttributes object by the userName.
      Parameters:
      userName - user name
      Returns:
      a populated AccountAttributes object or null if not found
    • getByUserName

      @Nullable @Nullable ResourceAttributes<?> getByUserName(String userName, ResourceQuery.AttributesEnumeration attributesEnumeration)
      Retrieve an AccountAttributes object by the userName.
      Parameters:
      userName - user name
      attributesEnumeration - attributes inclusions or exclusions
      Returns:
      a populated AccountAttributes object or null if not found
    • getByEmail

      @Nullable default @Nullable AccountAttributes getByEmail(String email)
      Retrieve an account by email.
      Parameters:
      email - email
      Returns:
      A populated AccountAttributes object or null if not found
    • getByEmail

      Retrieve an account by email.
      Parameters:
      email - email
      attributesEnumeration - attributes inclusions or exclusions
      Returns:
      A populated AccountAttributes object or null if not found
    • getByPhone

      @Nullable default @Nullable AccountAttributes getByPhone(String phone)
      Retrieve an AccountAttributes by phone number.
      Parameters:
      phone - phone
      Returns:
      A populated AccountAttributes object or null if not found
    • getByPhone

      Retrieve an AccountAttributes by phone number.
      Parameters:
      phone - phone
      attributesEnumeration - attributes inclusions or exclusions
      Returns:
      A populated AccountAttributes object or null if not found
    • create

      Create a new account.
      Parameters:
      account - to create
      Returns:
      the account, reflecting it as it is in the database after creation.
    • update

      ResourceAttributes<?> update(AccountAttributes account, ResourceQuery.AttributesEnumeration attributesEnumeration)
      Update an existing account.
      Parameters:
      account - to update
      attributesEnumeration - the enumerated attributes to return in the result
      Returns:
      the updated account after the update is performed.
    • update

      @Nullable @Nullable ResourceAttributes<?> update(String accountId, Map<String,Object> updateMap, ResourceQuery.AttributesEnumeration attributesEnumeration)
      Update an existing account.
      Parameters:
      accountId - ID of account to be updated
      updateMap - map of updates
      attributesEnumeration - the enumerated attributes to return in the result
      Returns:
      the updated account after the update is performed, or null if no account with such ID exists.
    • patch

      @Nullable @Nullable ResourceAttributes<?> patch(String accountId, AttributeUpdate attributeUpdate, ResourceQuery.AttributesEnumeration attributesEnumeration)
      Patch an existing account.
      Parameters:
      accountId - ID of account to be updated
      attributeUpdate - containing the attributes to patch
      attributesEnumeration - the enumerated attributes to return in the result
      Returns:
      the updated account after the update is performed, or null if no account with such ID exists.
    • activate

      default ResourceAttributes<?> activate(AccountAttributes account)
      Activate an existing account.
      Parameters:
      account - to activate
      Returns:
      the updated account containing ONLY the mandatory attributes
    • link

      void link(String linkingAccountManager, String localAccountId, String foreignDomainName, String foreignUserName)
      Link a foreign account ID and domain to the given local AccountId.

      Local means the account that resides in the data store of this DataAccessProvider. Foreign means an account that belongs to some other data store, or user source. This could be another data base, but might as well be a social account ID such as Facebook or Google.

      Parameters:
      linkingAccountManager - The account manager responsible for linking
      localAccountId - The account that should host the link
      foreignDomainName - The domain of account that should be added as linked to the local account
      foreignUserName - The account Id that should be linked to the local account.
    • listLinks

      Collection<LinkedAccount> listLinks(String linkingAccountManager, String localAccountId)
      Returns all linked accounts connected to a local account ID.
      Parameters:
      linkingAccountManager - The account manager used when the link was created
      localAccountId - The local account ID
      Returns:
      A collection of LinkedAccounts, empty if none exists
      Since:
      3.0.0
    • resolveLink

      @Nullable @Nullable AccountAttributes resolveLink(String linkingAccountManager, String foreignDomainName, String foreignAccountId)
      Given a foreign domain and ID (example "facebook" and "user-XYZ-123"), return any local account that "owns" the linked account, or null if none was found.
      Parameters:
      linkingAccountManager - The account manager used when the link was created
      foreignDomainName - The domain name of the foreign account
      foreignAccountId - The ID in the foreign domain
      Returns:
      The local AccountAttributes of the account or null if none exists
      Since:
      3.0.0
    • deleteLink

      boolean deleteLink(String linkingAccountManager, String localAccountId, String foreignDomainName, String foreignAccountId)
      Delete a linked account given the local account ID, the foreign domain name and ID.
      Parameters:
      linkingAccountManager - The account manager used when the link was created
      localAccountId - The local account ID
      foreignDomainName - The foreign domain name
      foreignAccountId - The foreign account ID
      Returns:
      true if a linked account was found and deleted, false otherwise
      Since:
      3.0.0
    • delete

      void delete(String accountId)
      Delete the user account with the given ID.
      Parameters:
      accountId - ID of the account