Class AuthorizationErrorResponseExceptionHandler

java.lang.Object
io.micronaut.security.oauth2.endpoint.authorization.response.AuthorizationErrorResponseExceptionHandler
All Implemented Interfaces:
io.micronaut.http.server.exceptions.ExceptionHandler<AuthorizationErrorResponseException,io.micronaut.http.MutableHttpResponse<?>>

@Requires(classes=io.micronaut.http.server.exceptions.ExceptionHandler.class) @Requires(beans=io.micronaut.http.server.exceptions.response.ErrorResponseProcessor.class) @Singleton public class AuthorizationErrorResponseExceptionHandler extends Object implements io.micronaut.http.server.exceptions.ExceptionHandler<AuthorizationErrorResponseException,io.micronaut.http.MutableHttpResponse<?>>
An exception handler for AuthorizationErrorResponseException.
Since:
1.2.0
Author:
Sergio del Amo
  • Constructor Details

    • AuthorizationErrorResponseExceptionHandler

      public AuthorizationErrorResponseExceptionHandler(RedirectConfiguration redirectConfiguration, RedirectService redirectService, io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> errorResponseProcessor)
      Parameters:
      redirectConfiguration - Redirect Configuration
      redirectService - Redirect Service
      errorResponseProcessor - Error Response Processor
  • Method Details

    • handle

      public io.micronaut.http.MutableHttpResponse<?> handle(io.micronaut.http.HttpRequest request, AuthorizationErrorResponseException exception)
      Specified by:
      handle in interface io.micronaut.http.server.exceptions.ExceptionHandler<AuthorizationErrorResponseException,io.micronaut.http.MutableHttpResponse<?>>
    • httpResponseWithStatus

      @NonNull protected @NonNull io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus(@NonNull @NonNull URI location)
      Builds a HTTP Response redirection to the supplied location.
      Parameters:
      location - The Uri to redirect to
      Returns:
      an HTTP response with the Uri as location
    • httpResponseWithStatus

      @NonNull protected @NonNull io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request, @NonNull @NonNull AuthorizationErrorResponseException exception)
      Parameters:
      request - The request
      exception - The exception
      Returns:
      The response to be used when a redirect is not appropriate
    • getRedirectUri

      @NonNull protected @NonNull String getRedirectUri(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request, @NonNull @NonNull AuthorizationErrorResponseException exception)
      Parameters:
      request - The request
      exception - The exception
      Returns:
      The URI to redirect to
    • shouldRedirect

      protected boolean shouldRedirect(@NonNull @NonNull io.micronaut.http.HttpRequest<?> request, @NonNull @NonNull AuthorizationErrorResponseException exception)
      Decides whether the request should be handled with a redirect.
      Parameters:
      request - The HTTP Request
      exception - The authorization exception
      Returns:
      true if the request accepts text/html