Class WhoOneTimeTokenService

java.lang.Object
org.jwcarman.who.emaillink.WhoOneTimeTokenService
All Implemented Interfaces:
org.springframework.security.authentication.ott.OneTimeTokenService

public class WhoOneTimeTokenService extends Object implements org.springframework.security.authentication.ott.OneTimeTokenService
Spring Security OneTimeTokenService for email links.

generate(GenerateOneTimeTokenRequest) only creates a random value and touches no table, so it takes the same time whether or not the address is known; EmailLinkIssuer stores the token later, on another thread. consume(OneTimeTokenAuthenticationToken) is never used: EmailLinkAuthenticationProvider redeems sign-ins itself, by link token or by code.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new service.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.authentication.ott.OneTimeToken
    consume(org.springframework.security.authentication.ott.OneTimeTokenAuthenticationToken authenticationToken)
    Not supported; EmailLinkAuthenticationProvider redeems sign-ins.
    org.springframework.security.authentication.ott.OneTimeToken
    generate(org.springframework.security.authentication.ott.GenerateOneTimeTokenRequest request)
    Generates a random token for the requested address without storing anything.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WhoOneTimeTokenService

      public WhoOneTimeTokenService(Clock clock, Duration tokenTtl)
      Creates a new service.
      Parameters:
      clock - the clock
      tokenTtl - how long a token stays valid
  • Method Details

    • generate

      public org.springframework.security.authentication.ott.OneTimeToken generate(org.springframework.security.authentication.ott.GenerateOneTimeTokenRequest request)
      Generates a random token for the requested address without storing anything.
      Specified by:
      generate in interface org.springframework.security.authentication.ott.OneTimeTokenService
      Parameters:
      request - the request; its username is the address
      Returns:
      the token
    • consume

      public org.springframework.security.authentication.ott.OneTimeToken consume(org.springframework.security.authentication.ott.OneTimeTokenAuthenticationToken authenticationToken)
      Not supported; EmailLinkAuthenticationProvider redeems sign-ins.
      Specified by:
      consume in interface org.springframework.security.authentication.ott.OneTimeTokenService
      Parameters:
      authenticationToken - ignored
      Returns:
      never
      Throws:
      UnsupportedOperationException - always