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 Summary
FieldsModifier and TypeFieldDescriptionprivate final OttDeliveryPort that delivers e-mail.private final SmsSenderPort that sends text messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeliverEmailCode(EmailCodeRequested request) E-mails a code.voiddeliverEmailLink(EmailLinkRequested request) E-mails a magic link.voiddeliverSms(SmsRequested request) Sends a text message.
-
Field Details
-
ottDelivery
Port that delivers e-mail. -
smsSender
Port that sends text messages.
-
-
Constructor Details
-
DeliverOneTimeTokenUseCase
public DeliverOneTimeTokenUseCase()
-
-
Method Details
-
deliverEmailCode
E-mails a code.- Parameters:
request- what to deliver.- Throws:
OttDeliveryException- if the mail could not be delivered.
-
deliverEmailLink
E-mails a magic link.- Parameters:
request- what to deliver.- Throws:
OttDeliveryException- if the mail could not be delivered.
-
deliverSms
Sends a text message.- Parameters:
request- what to send.- Throws:
SmsDeliveryException- if the gateway failed or refused the message.
-