Record Class PendingOtt

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.api.web.ott.PendingOtt
Record Components:
identifier - identifier (the user name) the token was requested for, as the user typed it.
bindingId - random identifier that ties the numeric code to this session.
kind - whether the token is a numeric code or a magic link.
purpose - whether the token signs the user in or is a second factor.
channel - channel the token is delivered through.
All Implemented Interfaces:
Serializable

public record PendingOtt(String identifier, String bindingId, OttKind kind, OttPurpose purpose, OttChannel channel) extends Record implements Serializable
The one-time token a browser has asked for and not used yet, kept in its session: for whom, through which channel, of which kind and for what purpose, and the binding id the numeric code was stored with. A code only works in the browser that holds its binding id, which is what makes a code typed in another browser worthless. The session holds one pending token: asking again replaces it (and so invalidates the previous code).
See Also:
  • Field Details

    • identifier

      private final String identifier
      The field for the identifier record component.
    • bindingId

      private final String bindingId
      The field for the bindingId record component.
    • kind

      private final OttKind kind
      The field for the kind record component.
    • purpose

      private final OttPurpose purpose
      The field for the purpose record component.
    • channel

      private final OttChannel channel
      The field for the channel record component.
    • serialVersionUID

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

      static final String ATTRIBUTE
      Name of the session attribute that holds the pending token.
  • Constructor Details

    • PendingOtt

      public PendingOtt(String identifier, String bindingId, OttKind kind, OttPurpose purpose, OttChannel channel)
      Creates an instance of a PendingOtt record class.
      Parameters:
      identifier - the value for the identifier record component
      bindingId - the value for the bindingId record component
      kind - the value for the kind record component
      purpose - the value for the purpose record component
      channel - the value for the channel record component
  • Method Details

    • saveTo

      public void saveTo(jakarta.servlet.http.HttpSession session)
      Keeps this pending token in a session, replacing the previous one.
      Parameters:
      session - the session.
    • of

      public static Optional<PendingOtt> of(jakarta.servlet.http.HttpServletRequest request)
      Finds the pending token of the session of a request, without creating a session.
      Parameters:
      request - the request.
      Returns:
      the pending token, or empty when the request has no session or the session holds none.
    • clear

      public static void clear(jakarta.servlet.http.HttpServletRequest request)
      Forgets the pending token of the session of a request, once it has been used.
      Parameters:
      request - the request.
    • toString

      public String toString()
      Describes the pending token without the binding id, which authorizes a code.
      Specified by:
      toString in class Record
      Returns:
      the kind, purpose and channel only.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • identifier

      public String identifier()
      Returns the value of the identifier record component.
      Returns:
      the value of the identifier record component
    • bindingId

      public String bindingId()
      Returns the value of the bindingId record component.
      Returns:
      the value of the bindingId record component
    • kind

      public OttKind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • purpose

      public OttPurpose purpose()
      Returns the value of the purpose record component.
      Returns:
      the value of the purpose record component
    • channel

      public OttChannel channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component