Class MfaExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler
com.irurueta.authserver.authorization.api.web.mfa.MfaExceptionHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware
@RestControllerAdvice(assignableTypes={TotpApi.class,RecoveryCodesApi.class,TrustedDevicesApi.class})
public class MfaExceptionHandler
extends ProblemJsonExceptionHandler
Translates the failures of the authenticator app, recovery code and trusted device endpoints to RFC 9457 problem
details, answered as
application/problem+json. It is scoped to the generated interfaces of those
endpoints, so it covers their controllers without depending on the packages they live in. Request validation
failures are handled by the parent class. A missing step-up (StepUpGuard) is answered as RFC 9470 describes.-
Field Summary
FieldsFields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleAlreadyEnabled(TotpAlreadyEnabledException exception) Answers an enrolment of an authenticator app that is already enabled.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> Answers a device the account does not have.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> Answers a token whose sign-in is not recent or strong enough:401with the RFC 9470 challenge, which tells the client whichacr_valuesandmax_ageto ask for when it signs the user in again.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidCode(InvalidTotpCodeException exception) Answers a wrong code.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleNotEnrolled(TotpNotEnrolledException exception) Answers a confirmation without an enrolment in progress, or a request for recovery codes from an account without a confirmed authenticator app.private static org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> Builds a problem response.Methods inherited from class com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler
createResponseEntity, problemResponse, problemResponseMethods inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
createProblemDetail, getMessageSource, handleAsyncRequestNotUsableException, handleAsyncRequestTimeoutException, handleConversionNotSupported, handleErrorResponseException, handleException, handleExceptionInternal, handleHandlerMethodValidationException, handleHttpMediaTypeNotAcceptable, handleHttpMediaTypeNotSupported, handleHttpMessageNotReadable, handleHttpMessageNotWritable, handleHttpRequestMethodNotSupported, handleMaxUploadSizeExceededException, handleMethodArgumentNotValid, handleMethodValidationException, handleMissingPathVariable, handleMissingServletRequestParameter, handleMissingServletRequestPart, handleNoHandlerFoundException, handleNoResourceFoundException, handleServletRequestBindingException, handleTypeMismatch, setMessageSource
-
Field Details
-
TYPE_BASE
Base of the problem type URNs.- See Also:
-
-
Constructor Details
-
MfaExceptionHandler
public MfaExceptionHandler()
-
-
Method Details
-
handleAlreadyEnabled
@ExceptionHandler(com.irurueta.authserver.authorization.domain.totp.TotpAlreadyEnabledException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleAlreadyEnabled(TotpAlreadyEnabledException exception) Answers an enrolment of an authenticator app that is already enabled.- Parameters:
exception- the failure.- Returns:
- the
409problem detail.
-
handleNotEnrolled
@ExceptionHandler(com.irurueta.authserver.authorization.domain.totp.TotpNotEnrolledException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleNotEnrolled(TotpNotEnrolledException exception) Answers a confirmation without an enrolment in progress, or a request for recovery codes from an account without a confirmed authenticator app.- Parameters:
exception- the failure.- Returns:
- the
400problem detail.
-
handleInvalidCode
@ExceptionHandler(com.irurueta.authserver.authorization.domain.totp.InvalidTotpCodeException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidCode(InvalidTotpCodeException exception) Answers a wrong code.- Parameters:
exception- the failure.- Returns:
- the
400problem detail.
-
handleDeviceNotFound
@ExceptionHandler(TrustedDeviceNotFoundException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleDeviceNotFound(TrustedDeviceNotFoundException exception) Answers a device the account does not have.- Parameters:
exception- the failure.- Returns:
- the
404problem detail.
-
handleInsufficientUserAuthentication
@ExceptionHandler(InsufficientUserAuthenticationException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInsufficientUserAuthentication(InsufficientUserAuthenticationException exception) Answers a token whose sign-in is not recent or strong enough:401with the RFC 9470 challenge, which tells the client whichacr_valuesandmax_ageto ask for when it signs the user in again.- Parameters:
exception- the failure.- Returns:
- the
401problem detail with theWWW-Authenticatechallenge.
-
respond
private static org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> respond(org.springframework.http.HttpStatus status, String type, String title, String detail) Builds a problem response.- Parameters:
status- HTTP status.type- last segment of the problem type.title- short summary.detail- explanation.- Returns:
- the response.
-