Class InMemoryOneTimeTokenRepository

java.lang.Object
com.codename1.backend.security.mail.InMemoryOneTimeTokenRepository
All Implemented Interfaces:
OneTimeTokenRepository

public final class InMemoryOneTimeTokenRepository extends Object implements OneTimeTokenRepository
Tokens kept in this process: gone when it stops, and unknown to any other server. For development and tests; see JdbcOneTimeTokenRepository otherwise.
  • Constructor Details

    • InMemoryOneTimeTokenRepository

      public InMemoryOneTimeTokenRepository()
  • Method Details

    • save

      public void save(String tokenHash, String purpose, String username, long now, long expiresAt)
      Description copied from interface: OneTimeTokenRepository

      Keeps a token for username, in place of any that user had for purpose: the newest link is the only one that works.

      Parameters
      • tokenHash: the token's hash
      • purpose: what the token may be used for
      • username: whose it is
      • now: the moment, epoch milliseconds; tokens that expired before it may be dropped
      • expiresAt: when the token stops working, epoch milliseconds
      Specified by:
      save in interface OneTimeTokenRepository
    • consume

      public String consume(String tokenHash, String purpose, long now)
      Description copied from interface: OneTimeTokenRepository
      Uses a token up. Answers the user it was given to, or null when there is none for purpose, it has expired, or another caller used it first: of two callers with one token, one is answered.
      Specified by:
      consume in interface OneTimeTokenRepository
    • removeAll

      public void removeAll(String username, String purpose)
      Description copied from interface: OneTimeTokenRepository
      Drops every token username has for purpose.
      Specified by:
      removeAll in interface OneTimeTokenRepository