java.lang.Object
com.irurueta.authserver.authorization.application.social.LinkIdentityUseCase

@Service @Transactional public class LinkIdentityUseCase extends Object
Use case that links an identity of an external provider to the account of a signed-in user. Unlike the sign-in, it does not depend on the e-mail address: the user proved to own the account by being signed in, and the provider by having just authenticated. The identity is locked first, as the sign-in does, so a concurrent sign-in or link of the same identity is serialized with it.
  • Field Details

    • federatedIdentityRepository

      private final FederatedIdentityRepository federatedIdentityRepository
      Port that stores the links.
    • recordSecurityEventUseCase

      private final RecordSecurityEventUseCase recordSecurityEventUseCase
      Use case that records the audit events.
    • clock

      private final Clock clock
      Source of the current time.
  • Constructor Details

    • LinkIdentityUseCase

      public LinkIdentityUseCase()
  • Method Details

    • execute

      public FederatedIdentity execute(UUID userId, String username, IdentityProvider provider, String subject, String email)
      Links an identity to an account. Linking an identity the account already has changes nothing.
      Parameters:
      userId - identifier of the signed-in user.
      username - name of the signed-in account, for the audit log.
      provider - provider that authenticated the user.
      subject - stable identifier the provider assigned to the user.
      email - e-mail address the provider reported, or null.
      Returns:
      the link.
      Throws:
      FederatedIdentityAlreadyLinkedException - if the identity belongs to another account.