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
FieldsModifier and TypeFieldDescriptionprivate final MfaExceptionHandlerBuilds the step-up challenge.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 token whose sign-in is not recent or strong enough:401with the RFC 9470 challenge.org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleInvalidLabel(InvalidPasskeyLabelException exception) 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 a500.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).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
Builds the step-up challenge.
-
-
Constructor Details
-
PasskeyExceptionHandler
public PasskeyExceptionHandler()
-
-
Method Details
-
handleNotFound
@ExceptionHandler(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
404problem detail.
-
handleInvalidLabel
@ExceptionHandler(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 a400: any otherIllegalArgumentExceptionis a programming error and stays a500.- Parameters:
exception- the failure.- Returns:
- the
400problem 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 a500.- Parameters:
exception- the failure.- Returns:
- the
400problem 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.- 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.
-