Interface SignedTokenService

All Known Implementing Classes:
NimbusSignedTokenService

public interface SignedTokenService
Port that issues and verifies signed, purpose-bound tokens. See the package documentation for its contract.
  • Field Details

    • PURPOSE_CLAIM

      static final String PURPOSE_CLAIM
      Name of the claim that carries the purpose of a signed token. A bearer-token consumer can reject any token carrying it, so a purpose-bound token is never mistaken for an access token.
      See Also:
  • Method Details

    • issue

      String issue(String subject, String purpose, Duration ttl)
      Issues a signed token.
      Parameters:
      subject - who or what the token is about.
      purpose - what the token allows; it must be presented again to verify it.
      ttl - how long the token stays valid.
      Returns:
      the compact token.
    • verify

      Optional<String> verify(String token, String purpose)
      Verifies a token.
      Parameters:
      token - the compact token.
      purpose - purpose the token must have been issued for.
      Returns:
      the subject of the token, or an empty optional when the token is not valid for that purpose.