Class OttExceptionHandler
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler
com.irurueta.authserver.authorization.api.web.ott.OttExceptionHandler
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware
@RestControllerAdvice(assignableTypes=PhoneApi.class)
public class OttExceptionHandler
extends ProblemJsonExceptionHandler
Translates the failures of the phone endpoints to RFC 9457 problem details, answered as
application/problem+json. It is scoped to the generated PhoneApi, so it covers its controller
without depending on the package it lives in. Request validation failures are handled by the parent class. A
missing step-up is answered as the multi-factor handler does. The messages never say which numbers are registered.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MfaExceptionHandlerAnswers a missing step-up.private static final StringBase of the problem type URNs.Fields 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> Answers a number of a country SMS messages are not sent to.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> Answers a token whose sign-in is not recent or strong enough to remove the phone.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidCode(InvalidPhoneCodeException exception) Answers a wrong, expired or missing verification code.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidPhone(InvalidPhoneNumberException exception) Answers a number that is not a valid phone number.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleNotFound(PhoneNotFoundException exception) Answers an account without a verified phone.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleRateLimited(OttRateLimitExceededException exception) Answers a client or an account that asked or tried too many times, telling when to retry.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:
-
mfaExceptionHandler
Answers a missing step-up.
-
-
Constructor Details
-
OttExceptionHandler
public OttExceptionHandler()
-
-
Method Details
-
handleNotFound
@ExceptionHandler(PhoneNotFoundException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleNotFound(PhoneNotFoundException exception) Answers an account without a verified phone.- Parameters:
exception- the failure.- Returns:
- the
404problem detail.
-
handleInvalidPhone
@ExceptionHandler(com.irurueta.authserver.authorization.application.sms.InvalidPhoneNumberException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidPhone(InvalidPhoneNumberException exception) Answers a number that is not a valid phone number.- Parameters:
exception- the failure.- Returns:
- the
400problem detail.
-
handleCountryNotAllowed
@ExceptionHandler(com.irurueta.authserver.authorization.application.sms.SmsCountryNotAllowedException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleCountryNotAllowed(SmsCountryNotAllowedException exception) Answers a number of a country SMS messages are not sent to.- Parameters:
exception- the failure.- Returns:
- the
400problem detail.
-
handleInvalidCode
@ExceptionHandler(InvalidPhoneCodeException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidCode(InvalidPhoneCodeException exception) Answers a wrong, expired or missing verification code.- Parameters:
exception- the failure.- Returns:
- the
400problem detail.
-
handleRateLimited
@ExceptionHandler(OttRateLimitExceededException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleRateLimited(OttRateLimitExceededException exception) Answers a client or an account that asked or tried too many times, telling when to retry.- Parameters:
exception- the failure.- Returns:
- the
429problem detail, with aRetry-Afterheader in seconds.
-
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 to remove the phone.- 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.
-