Class DeliverOneTimeTokenUseCase

java.lang.Object
com.irurueta.authserver.authorization.application.ott.DeliverOneTimeTokenUseCase

@Service @Transactional(propagation=NOT_SUPPORTED) public class DeliverOneTimeTokenUseCase extends Object
Delivers what the one-time token use cases asked for: an e-mailed code or link, or a text message whose cost was already recorded. It is called once the transaction that stored the token has committed, off the request thread, and it runs outside any transaction (Propagation.NOT_SUPPORTED) because it only calls remote services: a transaction would hold a database connection for as long as the mail server or the SMS gateway takes. A failure is thrown to the caller, which records it; it never reaches the response of the request that asked for the token.
  • Field Details

    • ottDelivery

      private final OttDelivery ottDelivery
      Port that delivers e-mail.
    • smsSender

      private final SmsSender smsSender
      Port that sends text messages.
  • Constructor Details

    • DeliverOneTimeTokenUseCase

      public DeliverOneTimeTokenUseCase()
  • Method Details

    • deliverEmailCode

      public void deliverEmailCode(EmailCodeRequested request)
      E-mails a code.
      Parameters:
      request - what to deliver.
      Throws:
      OttDeliveryException - if the mail could not be delivered.
    • deliverEmailLink

      public void deliverEmailLink(EmailLinkRequested request)
      E-mails a magic link.
      Parameters:
      request - what to deliver.
      Throws:
      OttDeliveryException - if the mail could not be delivered.
    • deliverSms

      public void deliverSms(SmsRequested request)
      Sends a text message.
      Parameters:
      request - what to send.
      Throws:
      SmsDeliveryException - if the gateway failed or refused the message.