Record Class OttGenerationParameters

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.api.web.ott.OttGenerationParameters
Record Components:
channel - channel the token is delivered through.
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 of a signed-in user.

public record OttGenerationParameters(OttChannel channel, OttKind kind, OttPurpose purpose) extends Record
What a request to POST /ott/generate asks for, read from its form fields: through which channel, a numeric code or a magic link, and for a sign-in or as a second factor. Every unknown or missing value falls back to the default (an e-mail code for a sign-in), so a malformed request is answered like any other.
  • Field Details

    • channel

      private final OttChannel channel
      The field for the channel 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.
    • USERNAME_PARAMETER

      public static final String USERNAME_PARAMETER
      Name of the field that holds the identifier (the user name) of a sign-in.
      See Also:
    • CHANNEL_PARAMETER

      public static final String CHANNEL_PARAMETER
      Name of the field that holds the channel, email (default) or sms.
      See Also:
    • KIND_PARAMETER

      public static final String KIND_PARAMETER
      Name of the field that holds the kind of token, code (default) or link.
      See Also:
    • PURPOSE_PARAMETER

      public static final String PURPOSE_PARAMETER
      Name of the field that holds the purpose, login (default) or second-factor.
      See Also:
    • SMS_VALUE

      public static final String SMS_VALUE
      Value of the channel field that selects SMS.
      See Also:
    • SECOND_FACTOR_VALUE

      public static final String SECOND_FACTOR_VALUE
      Value of the purpose field that selects the second factor.
      See Also:
  • Constructor Details

    • OttGenerationParameters

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

    • from

      public static OttGenerationParameters from(jakarta.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication current)
      Reads the parameters of a request. A magic link is only sent by e-mail, so an SMS request is always a code, and a second factor is only possible for a user who is signed in: for anybody else the request is a sign-in.
      Parameters:
      request - the request.
      current - the authentication of the request, or null.
      Returns:
      the parameters.
    • isSignedIn

      static boolean isSignedIn(org.springframework.security.core.Authentication authentication)
      Tells whether an authentication is a signed-in user.
      Parameters:
      authentication - the authentication, or null.
      Returns:
      true when it is authenticated and not anonymous.
    • lowerCase

      private static String lowerCase(String value)
      Lower-cases a value, whatever the platform's locale is.
      Parameters:
      value - the value, or null.
      Returns:
      the value in lower case; the empty text for null.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
    • channel

      public OttChannel channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel 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