Class TotpAuthenticationToken

java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
com.irurueta.authserver.authorization.api.web.totp.TotpAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, org.springframework.security.core.Authentication, org.springframework.security.core.CredentialsContainer

public class TotpAuthenticationToken extends org.springframework.security.authentication.AbstractAuthenticationToken
Request to verify a second factor: the authentication the user already holds (the primary factor) and the code the user typed, and what kind of code it is. It is never authenticated itself; TotpAuthenticationProvider answers with the primary authentication enriched with the TOTP authority and, when the code confirmed an enrolment, hands the new recovery codes back to the filter through issueRecoveryCodes(List).
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.security.authentication.AbstractAuthenticationToken

    org.springframework.security.authentication.AbstractAuthenticationToken.AbstractAuthenticationBuilder<B extends org.springframework.security.authentication.AbstractAuthenticationToken.AbstractAuthenticationBuilder<B>>

    Nested classes/interfaces inherited from interface org.springframework.security.core.Authentication

    org.springframework.security.core.Authentication.Builder<B extends org.springframework.security.core.Authentication.Builder<B>>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    The code as typed.
    private List<String>
    Recovery codes generated while the request was verified (an enrolment), to be shown once; never serialized, as they only travel from the provider back to the filter of the same request.
    private final TotpCodeKind
    What kind of code it is.
    private final org.springframework.security.core.Authentication
    The authentication the user already holds.
    private static final long
    Serialization version.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TotpAuthenticationToken(org.springframework.security.core.Authentication primary, String code, TotpCodeKind kind)
    Creates the request.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the code.
    Gets the principal.
    Gets the recovery codes generated while the request was verified.
    void
    Hands back the recovery codes generated while the request was verified.
    Tells what kind of code it is.
    org.springframework.security.core.Authentication
    Gets the authentication the user already holds.

    Methods inherited from class org.springframework.security.authentication.AbstractAuthenticationToken

    equals, eraseCredentials, getAuthorities, getDetails, getName, hashCode, isAuthenticated, setAuthenticated, setDetails, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.security.core.Authentication

    toBuilder

    Methods inherited from interface java.security.Principal

    implies
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version.
      See Also:
    • primary

      private final org.springframework.security.core.Authentication primary
      The authentication the user already holds.
    • code

      private final String code
      The code as typed.
    • kind

      private final TotpCodeKind kind
      What kind of code it is.
    • issuedRecoveryCodes

      private transient List<String> issuedRecoveryCodes
      Recovery codes generated while the request was verified (an enrolment), to be shown once; never serialized, as they only travel from the provider back to the filter of the same request.
  • Constructor Details

    • TotpAuthenticationToken

      public TotpAuthenticationToken(org.springframework.security.core.Authentication primary, String code, TotpCodeKind kind)
      Creates the request.
      Parameters:
      primary - the authentication the user already holds.
      code - the code as typed.
      kind - what kind of code it is.
  • Method Details

    • getCredentials

      public String getCredentials()
      Gets the code.
      Returns:
      the code as typed.
    • getPrincipal

      public Object getPrincipal()
      Gets the principal.
      Returns:
      the principal of the primary authentication.
    • primary

      public org.springframework.security.core.Authentication primary()
      Gets the authentication the user already holds.
      Returns:
      the primary authentication.
    • kind

      public TotpCodeKind kind()
      Tells what kind of code it is.
      Returns:
      the kind of code.
    • issuedRecoveryCodes

      public List<String> issuedRecoveryCodes()
      Gets the recovery codes generated while the request was verified.
      Returns:
      the codes; empty unless the code confirmed an enrolment.
    • issueRecoveryCodes

      public void issueRecoveryCodes(List<String> codes)
      Hands back the recovery codes generated while the request was verified.
      Parameters:
      codes - the codes in clear text.