Class OttCodeAuthenticationToken

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

public class OttCodeAuthenticationToken extends org.springframework.security.authentication.AbstractAuthenticationToken
Request to sign in with a numeric one-time code: the code the user typed, the identifier it was requested for and the binding id of the session that requested it. It is never authenticated itself; OttCodeAuthenticationProvider answers with the authentication of the user.
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
    Binding id of the session that requested the code.
    private final String
    The code as typed.
    (package private) static final int
    Longest numeric code accepted, so a token value of digits is never mistaken for a code by length alone.
    private static final long
    Serialization version.
    private final String
    The identifier the code was requested for.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OttCodeAuthenticationToken(String username, String code, String bindingId)
    Creates the request.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the binding id of the session that requested the code.
    Gets the code.
    Gets the identifier the code was requested for.
    static boolean
    isCode(String value)
    Tells whether a submitted value is a numeric code rather than the token of a magic link (which is a UUID).

    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

    • MAX_CODE_LENGTH

      static final int MAX_CODE_LENGTH
      Longest numeric code accepted, so a token value of digits is never mistaken for a code by length alone.
      See Also:
    • serialVersionUID

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

      private final String username
      The identifier the code was requested for.
    • code

      private final String code
      The code as typed.
    • bindingId

      private final String bindingId
      Binding id of the session that requested the code.
  • Constructor Details

    • OttCodeAuthenticationToken

      public OttCodeAuthenticationToken(String username, String code, String bindingId)
      Creates the request.
      Parameters:
      username - the identifier the code was requested for, empty when the session requested none.
      code - the code as typed.
      bindingId - binding id of the session that requested the code, empty when it requested none.
  • Method Details

    • isCode

      public static boolean isCode(String value)
      Tells whether a submitted value is a numeric code rather than the token of a magic link (which is a UUID).
      Parameters:
      value - the value of the token field.
      Returns:
      true for one to 12 ASCII digits.
    • getCredentials

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

      public String getPrincipal()
      Gets the identifier the code was requested for.
      Returns:
      the identifier.
    • bindingId

      public String bindingId()
      Gets the binding id of the session that requested the code.
      Returns:
      the binding id.