Class SecondFactorController
java.lang.Object
com.irurueta.authserver.authorization.api.web.mfa.SecondFactorController
- All Implemented Interfaces:
SecondFactorPageApi
Serves the second-factor page, as the contract
apis/auth-server/web-pages/auth-server-pages-v1.yaml
describes it through the generated SecondFactorPageApi, supplying the ordered fragments of the second
factors, the model attributes each of them contributes for the signed-in user and the outcome of the last attempt to
the template.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringName of the model attribute that holds the key of the message of a failed attempt.private final List<SecondFactorFragment> Fragments contributed by the second factors, sorted by order.(package private) static final StringName of the model attribute that holds the fragments of the second factors.static final StringKey of the message shown when a code is wrong.static final StringKey of the message shown when the second factor is locked.private final PageRendererRenders the page.private final jakarta.servlet.http.HttpServletRequestThe current request, injected as a thread-bound proxy, whose session holds the last failure.static final StringPath of the second-factor page, taken from the contract.(package private) static final StringName of the second-factor template.Fields inherited from interface com.irurueta.authserver.authorization.api.web.pages.v1.generated.api.SecondFactorPageApi
PATH_SECOND_FACTOR_PAGE -
Constructor Summary
ConstructorsConstructorDescriptionSecondFactorController(List<SecondFactorFragment> factors, PageRenderer pageRenderer, jakarta.servlet.http.HttpServletRequest request) Creates the controller. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanTells whether the previous attempt failed because the second factor is locked, which Spring Security keeps in the session.org.springframework.http.ResponseEntity<String> secondFactorPage(String error) Renders the second-factor page.
-
Field Details
-
SECOND_FACTOR_PATH
Path of the second-factor page, taken from the contract.- See Also:
-
GENERIC_ERROR
Key of the message shown when a code is wrong.- See Also:
-
LOCKED_ERROR
Key of the message shown when the second factor is locked.- See Also:
-
VIEW_NAME
Name of the second-factor template.- See Also:
-
FRAGMENTS_ATTRIBUTE
Name of the model attribute that holds the fragments of the second factors.- See Also:
-
ERROR_MESSAGE_ATTRIBUTE
Name of the model attribute that holds the key of the message of a failed attempt.- See Also:
-
fragments
Fragments contributed by the second factors, sorted by order. -
pageRenderer
Renders the page. -
request
private final jakarta.servlet.http.HttpServletRequest requestThe current request, injected as a thread-bound proxy, whose session holds the last failure.
-
-
Constructor Details
-
SecondFactorController
public SecondFactorController(List<SecondFactorFragment> factors, PageRenderer pageRenderer, jakarta.servlet.http.HttpServletRequest request) Creates the controller.- Parameters:
factors- fragments contributed by the second factors.pageRenderer- renderer of the page.request- the current request.
-
-
Method Details
-
secondFactorPage
Renders the second-factor page.- Specified by:
secondFactorPagein interfaceSecondFactorPageApi- Parameters:
error- present (even if empty) when the previous attempt failed.- Returns:
- the second-factor 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:
truewhen the session holds aLockedExceptionas the last failure.
-