Class OttPagesController

java.lang.Object
com.irurueta.authserver.authorization.api.web.ott.OttPagesController
All Implemented Interfaces:
OneTimeTokenPageApi

@Controller public class OttPagesController extends Object implements OneTimeTokenPageApi
Serves the two pages of the one-time token flow, as the contract apis/auth-server/web-pages/ auth-server-pages-v1.yaml describes them through the generated OneTimeTokenPageApi: the page where the code is entered (or that says to check the inbox when a magic link was requested) and the page a magic link opens, whose button posts the token. What the first one shows comes from the pending token of the session (see PendingOtt), so it is the same page whatever identifier was typed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final String
    Name of the model attribute that holds the channel, email or sms.
    (package private) static final String
    Name of the model attribute that holds the name of the form field of the code.
    (package private) static final String
    Value of the kind attribute of a numeric code.
    (package private) static final String
    Name of the template of the page where the code is entered.
    (package private) static final String
    Name of the template of the confirmation page.
    (package private) static final String
    Name of the model attribute that holds the key of the message of a failed attempt.
    (package private) static final String
    Name of the model attribute that holds the path a new token is requested at.
    (package private) static final String
    Key of the message shown when a code is wrong.
    (package private) static final String
    Name of the model attribute that holds the kind of token, code or link.
    (package private) static final String
    Key of the message shown when the second factor is locked.
    (package private) static final String
    Value of the purpose attribute of a sign-in.
    static final String
    Path of the page where the code is entered, taken from the contract.
    private final PageRenderer
    Renders the pages.
    (package private) static final String
    Name of the model attribute that tells whether this browser has asked for a token.
    (package private) static final String
    Name of the model attribute that holds the path the code form posts to.
    (package private) static final String
    Name of the model attribute that holds the purpose, login or second-factor.
    (package private) static final String
    Name of the header that tells browsers to send no referrer.
    private final jakarta.servlet.http.HttpServletRequest
    The current request, injected as a thread-bound proxy, whose session holds the pending token.
    (package private) static final String
    Name of the model attribute that holds the token of the magic link.

    Fields inherited from interface com.irurueta.authserver.authorization.api.web.pages.v1.generated.api.OneTimeTokenPageApi

    PATH_OTT_CODE_PAGE, PATH_OTT_CONFIRM_PAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private boolean
    Tells whether the previous attempt failed because the second factor is locked, which Spring Security keeps in the session.
    private static String
    Lower-cases a name, whatever the platform's locale is.
    org.springframework.http.ResponseEntity<String>
    Renders the page where the code is entered.
    org.springframework.http.ResponseEntity<String>
    Renders the page a magic link opens.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • OTT_CODE_PATH

      public static final String OTT_CODE_PATH
      Path of the page where the code is entered, taken from the contract.
      See Also:
    • CODE_VIEW_NAME

      static final String CODE_VIEW_NAME
      Name of the template of the page where the code is entered.
      See Also:
    • CONFIRM_VIEW_NAME

      static final String CONFIRM_VIEW_NAME
      Name of the template of the confirmation page.
      See Also:
    • PENDING_ATTRIBUTE

      static final String PENDING_ATTRIBUTE
      Name of the model attribute that tells whether this browser has asked for a token.
      See Also:
    • KIND_ATTRIBUTE

      static final String KIND_ATTRIBUTE
      Name of the model attribute that holds the kind of token, code or link.
      See Also:
    • CHANNEL_ATTRIBUTE

      static final String CHANNEL_ATTRIBUTE
      Name of the model attribute that holds the channel, email or sms.
      See Also:
    • PURPOSE_ATTRIBUTE

      static final String PURPOSE_ATTRIBUTE
      Name of the model attribute that holds the purpose, login or second-factor.
      See Also:
    • POST_PATH_ATTRIBUTE

      static final String POST_PATH_ATTRIBUTE
      Name of the model attribute that holds the path the code form posts to.
      See Also:
    • CODE_FIELD_ATTRIBUTE

      static final String CODE_FIELD_ATTRIBUTE
      Name of the model attribute that holds the name of the form field of the code.
      See Also:
    • GENERATE_PATH_ATTRIBUTE

      static final String GENERATE_PATH_ATTRIBUTE
      Name of the model attribute that holds the path a new token is requested at.
      See Also:
    • ERROR_MESSAGE_ATTRIBUTE

      static final String ERROR_MESSAGE_ATTRIBUTE
      Name of the model attribute that holds the key of the message of a failed attempt.
      See Also:
    • TOKEN_ATTRIBUTE

      static final String TOKEN_ATTRIBUTE
      Name of the model attribute that holds the token of the magic link.
      See Also:
    • GENERIC_ERROR

      static final String GENERIC_ERROR
      Key of the message shown when a code is wrong.
      See Also:
    • LOCKED_ERROR

      static final String LOCKED_ERROR
      Key of the message shown when the second factor is locked.
      See Also:
    • LOGIN_VALUE

      static final String LOGIN_VALUE
      Value of the purpose attribute of a sign-in.
      See Also:
    • CODE_VALUE

      static final String CODE_VALUE
      Value of the kind attribute of a numeric code.
      See Also:
    • REFERRER_POLICY

      static final String REFERRER_POLICY
      Name of the header that tells browsers to send no referrer.
      See Also:
    • pageRenderer

      private final PageRenderer pageRenderer
      Renders the pages.
    • request

      private final jakarta.servlet.http.HttpServletRequest request
      The current request, injected as a thread-bound proxy, whose session holds the pending token.
  • Constructor Details

    • OttPagesController

      public OttPagesController()
  • Method Details

    • ottCodePage

      public org.springframework.http.ResponseEntity<String> ottCodePage(String error)
      Renders the page where the code is entered.
      Specified by:
      ottCodePage in interface OneTimeTokenPageApi
      Parameters:
      error - present (even if empty) when the previous attempt failed.
      Returns:
      the page.
    • ottConfirmPage

      public org.springframework.http.ResponseEntity<String> ottConfirmPage(String token)
      Renders the page a magic link opens. It is never cached and a browser sends no referrer from it, because the token is in its address.
      Specified by:
      ottConfirmPage in interface OneTimeTokenPageApi
      Parameters:
      token - the token of the link, which is only posted back, never checked here.
      Returns:
      the confirmation page.
    • lastFailureWasLockout

      private boolean lastFailureWasLockout()
      Tells whether the previous attempt failed because the second factor is locked, which Spring Security keeps in the session.
      Returns:
      true when the session holds a LockedException as the last failure.
    • lowerCase

      private static String lowerCase(String name)
      Lower-cases a name, whatever the platform's locale is.
      Parameters:
      name - the name.
      Returns:
      the name in lower case.