Class SignInMethodExceptionHandler

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
com.irurueta.authserver.authorization.api.web.ProblemJsonExceptionHandler
com.irurueta.authserver.authorization.api.web.social.SignInMethodExceptionHandler
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware
Direct Known Subclasses:
CertificateExceptionHandler, IdentityExceptionHandler

public abstract class SignInMethodExceptionHandler extends ProblemJsonExceptionHandler
Base of the exception handlers of the APIs that remove a sign-in method of the account (the linked identities, the bound certificates): both refuse to remove the last way to sign in and both need a recent multi-factor sign-in, so both answer those failures the same way. The step-up challenge is the one the rest of the account API gives (MfaExceptionHandler), so a client handles the same 401 everywhere. Each subclass is the @RestControllerAdvice of its own API and names the base of its problem types.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final MfaExceptionHandler
    Builds the step-up challenge.
    private final String
    Base of the problem type URNs of the API, for example urn:problem:identity:.

    Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler

    logger, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates the handler.
  • 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 sign-in method that is the last way to sign in to the account.
    protected org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail>
    respond(org.springframework.http.HttpStatus status, String type, String title, String detail)
    Builds a problem response whose type is below the base of the API.

    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

    • typeBase

      private final String typeBase
      Base of the problem type URNs of the API, for example urn:problem:identity:.
    • mfaExceptionHandler

      private final MfaExceptionHandler mfaExceptionHandler
      Builds the step-up challenge.
  • Constructor Details

    • SignInMethodExceptionHandler

      protected SignInMethodExceptionHandler(String typeBase, MfaExceptionHandler mfaExceptionHandler)
      Creates the handler.
      Parameters:
      typeBase - base of the problem type URNs of the API.
      mfaExceptionHandler - builds the step-up challenge.
  • Method Details

    • handleLastSignInMethod

      @ExceptionHandler(LastSignInMethodException.class) public org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> handleLastSignInMethod(LastSignInMethodException exception)
      Answers a sign-in method that is the last way to sign in to the account.
      Parameters:
      exception - the failure.
      Returns:
      the 409 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

      protected org.springframework.http.ResponseEntity<org.springframework.http.ProblemDetail> respond(org.springframework.http.HttpStatus status, String type, String title, String detail)
      Builds a problem response whose type is below the base of the API.
      Parameters:
      status - HTTP status.
      type - last segment of the problem type.
      title - short summary.
      detail - explanation.
      Returns:
      the response.