Interface FederatedIdentityRepository


public interface FederatedIdentityRepository
Port that stores the identities of external providers linked to accounts. It never returns null.
  • Method Details

    • lockSubject

      void lockSubject(IdentityProvider provider, String subject)
      Serializes, until the caller's transaction ends, every caller that links or resolves the same identity of a provider, so that two first sign-ins of the same person never both try to link it: the second one waits and then finds the link of the first.
      Parameters:
      provider - provider that holds the identity.
      subject - stable identifier the provider assigned to the user.
    • findByProviderAndSubject

      Optional<FederatedIdentity> findByProviderAndSubject(IdentityProvider provider, String subject)
      Finds the link of a provider's subject.
      Parameters:
      provider - provider that holds the identity.
      subject - stable identifier the provider assigned to the user.
      Returns:
      the link, or an empty optional when that identity is not linked to any account.
    • findByUser

      List<FederatedIdentity> findByUser(UUID userId)
      Lists the identities linked to an account, oldest link first.
      Parameters:
      userId - identifier of the account.
      Returns:
      the links, possibly empty.
    • findByIdAndUser

      Optional<FederatedIdentity> findByIdAndUser(UUID id, UUID userId)
      Finds one link of an account.
      Parameters:
      id - identifier of the link.
      userId - identifier of the account, so nobody can reach another account's link.
      Returns:
      the link, or an empty optional when the account has no such link.
    • save

      Stores a link, inserting it or updating the e-mail address and last sign-in instant of an existing one.
      Parameters:
      identity - link to store.
      Returns:
      the stored link.
    • delete

      boolean delete(UUID id, UUID userId)
      Deletes a link of an account.
      Parameters:
      id - identifier of the link.
      userId - identifier of the account.
      Returns:
      true when a link was deleted.
    • countByUser

      long countByUser(UUID userId)
      Counts the identities linked to an account.
      Parameters:
      userId - identifier of the account.
      Returns:
      the number of links.