Class EmailLinkIssuer
java.lang.Object
org.jwcarman.who.emaillink.EmailLinkIssuer
Does the real work behind
POST /who/email/send, off the request thread: looks up the
address, stores the token's hash (the upsert that is also the resend limit), and sends the link.
Nothing here is visible to the /who/email/send caller, who has already been answered
202; that path ignores the EmailLinkOutcome. issue(String, String) never throws: every
failure is logged at WARN with only the credential id (when known) and the exception class, never
the exception message, the address or the token value.
Each call to issue(String, String) publishes one SignInEmailRequested with its outcome.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the observation around eachissue(String, String). -
Constructor Summary
ConstructorsConstructorDescriptionEmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock) Creates a new issuer that publishes no events.EmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock, WhoEventPublisher eventPublisher) Creates a new issuer that publishes events and records no observations.EmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock, WhoEventPublisher eventPublisher, io.micrometer.observation.ObservationRegistry observations) Creates a new issuer that observes eachissue(String, String)as "who.sign-in.email.issue". -
Method Summary
Modifier and TypeMethodDescriptionIssues and sends a link if the address belongs to an active identity and no recent link is outstanding, and reports what happened.
-
Field Details
-
ISSUE_OBSERVATION
The name of the observation around eachissue(String, String).- See Also:
-
-
Constructor Details
-
EmailLinkIssuer
public EmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock) Creates a new issuer that publishes no events.- Parameters:
credentialService- finds email credentialswhoService- resolves credentials to active identitiesrepository- stores token hashesemails- sends the linksettings- the link settingsclock- the clock
-
EmailLinkIssuer
public EmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock, WhoEventPublisher eventPublisher) Creates a new issuer that publishes events and records no observations.- Parameters:
credentialService- finds email credentialswhoService- resolves credentials to active identitiesrepository- stores token hashesemails- sends the linksettings- the link settingsclock- the clockeventPublisher- whereSignInEmailRequestedis published
-
EmailLinkIssuer
public EmailLinkIssuer(EmailCredentialService credentialService, WhoService whoService, EmailLinkTokenRepository repository, WhoEmails emails, EmailLinkSettings settings, Clock clock, WhoEventPublisher eventPublisher, io.micrometer.observation.ObservationRegistry observations) Creates a new issuer that observes eachissue(String, String)as "who.sign-in.email.issue".- Parameters:
credentialService- finds email credentialswhoService- resolves credentials to active identitiesrepository- stores token hashesemails- sends the linksettings- the link settingsclock- the clockeventPublisher- whereSignInEmailRequestedis publishedobservations- records an observation for each request, tagged with its outcome
-
-
Method Details
-
issue
Issues and sends a link if the address belongs to an active identity and no recent link is outstanding, and reports what happened. Never throws: a failure is logged and reported asEmailLinkOutcome.SEND_FAILED. Publishes oneSignInEmailRequestedwith the outcome.This method is synchronous. Call it with no transaction open, after your own transaction commits; it does its own writes and sends the email with none open.
- Parameters:
address- the requested address, as typed; the link goes to the registered (normalized) addresstokenValue- the generated token value- Returns:
- what became of the request
-