Class UnlinkIdentityUseCase

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

@Service @Transactional public class UnlinkIdentityUseCase extends Object
Use case that unlinks an identity of an external provider from an account and audits it. It refuses to remove the last way to sign in: the account must keep a password its owner knows, another linked identity, a passkey or a bound certificate. The methods are counted under the lock of LockSignInMethodsUseCase, so a concurrent removal (another identity, a certificate) of the same account waits and then counts what this one left.
  • Field Details

    • federatedIdentityRepository

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

      private final LockSignInMethodsUseCase lockSignInMethodsUseCase
      Locks and counts the sign-in methods of the account.
    • federatedLinkingPolicy

      private final FederatedLinkingPolicy federatedLinkingPolicy
      Rules of linking and unlinking.
    • recordSecurityEventUseCase

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

    • UnlinkIdentityUseCase

      public UnlinkIdentityUseCase()
  • Method Details

    • execute

      public void execute(UUID userId, String username, UUID id)
      Unlinks an identity; an identity of another account is never touched.
      Parameters:
      userId - identifier of the signed-in user.
      username - name of the signed-in account, for the audit log.
      id - identifier of the link.
      Throws:
      FederatedIdentityNotFoundException - if the account has no such link.
      LastSignInMethodException - if the link is the last way the account can sign in.