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

    Fields
    Modifier and Type
    Field
    Description
    private final MfaExceptionHandler
    Answers a missing step-up.
    private static final String
    Base 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.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>
    Answers a wrong, expired or missing verification code.
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    Answers a number that is not a valid phone number.
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    Answers an account without a verified phone.
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    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>
    respond(org.springframework.http.HttpStatus status, String type, String title, String detail)
    Builds a problem response.

    Methods inherited from class com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler

    createResponseEntity, problemResponse, problemResponse

    Methods 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

    Methods inherited from class java.lang.Object

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

  • 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 404 problem detail.
    • handleInvalidPhone

      @ExceptionHandler(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 400 problem detail.
    • handleCountryNotAllowed

      @ExceptionHandler(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 400 problem 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 400 problem 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 429 problem detail, with a Retry-After header 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 401 problem detail with the WWW-Authenticate challenge.
    • 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.