Class PasskeyExceptionHandler

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler
com.irurueta.authserver.authorization.api.web.passkeys.PasskeyExceptionHandler
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware

@RestControllerAdvice(assignableTypes=PasskeysApi.class) public class PasskeyExceptionHandler extends ProblemJsonExceptionHandler
Answers the failures of the passkeys API as application/problem+json. The step-up challenge is the one the rest of the account API gives (MfaExceptionHandler, whose scope is the TOTP, recovery code and trusted device interfaces), so a client handles the same 401 everywhere.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final MfaExceptionHandler
    Builds the step-up challenge.
    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 token whose sign-in is not recent or strong enough: 401 with the RFC 9470 challenge.
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    Answers a label the use case refuses (blank, or too long once trimmed).
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    handleInvalidParameter(jakarta.validation.ConstraintViolationException exception)
    Answers a path parameter that breaks the constraints of the contract (an identifier that is not unpadded base64url): the validation of the generated interface throws it, and without this answer it would be a 500.
    org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    Answers a passkey the account does not have (another account's passkey is answered the same way).
    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

    • PasskeyExceptionHandler

      public PasskeyExceptionHandler()
  • Method Details

    • handleNotFound

      @ExceptionHandler(com.irurueta.authserver.authorization.domain.passkeys.PasskeyNotFoundException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleNotFound(PasskeyNotFoundException exception)
      Answers a passkey the account does not have (another account's passkey is answered the same way).
      Parameters:
      exception - the failure.
      Returns:
      the 404 problem detail.
    • handleInvalidLabel

      @ExceptionHandler(com.irurueta.authserver.authorization.domain.passkeys.InvalidPasskeyLabelException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidLabel(InvalidPasskeyLabelException exception)
      Answers a label the use case refuses (blank, or too long once trimmed). Only that domain exception is answered as a 400: any other IllegalArgumentException is a programming error and stays a 500.
      Parameters:
      exception - the failure.
      Returns:
      the 400 problem detail.
    • handleInvalidParameter

      @ExceptionHandler(jakarta.validation.ConstraintViolationException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidParameter(jakarta.validation.ConstraintViolationException exception)
      Answers a path parameter that breaks the constraints of the contract (an identifier that is not unpadded base64url): the validation of the generated interface throws it, and without this answer it would be a 500.
      Parameters:
      exception - the failure.
      Returns:
      the 400 problem 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: 401 with the RFC 9470 challenge.
      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.