Class AuthorizationErrorResponseExceptionHandler

    • Constructor Detail

      • AuthorizationErrorResponseExceptionHandler

        @Inject
        public AuthorizationErrorResponseExceptionHandler​(@Nullable
                                                          io.micronaut.security.config.RedirectConfiguration redirectConfiguration,
                                                          @Nullable
                                                          io.micronaut.security.config.RedirectService redirectService,
                                                          @Nullable
                                                          io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> errorResponseProcessor)
        Parameters:
        redirectConfiguration - Redirect Configuration
        redirectService - Redirect Service
        errorResponseProcessor - Error Response Processor
      • AuthorizationErrorResponseExceptionHandler

        @Deprecated
        public AuthorizationErrorResponseExceptionHandler()
        Deprecated.
        This will be removed in the next major version, so that this class uses the ErrorProcessor API
        Default constructor.
    • Method Detail

      • httpResponseWithStatus

        @NonNull
        protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus​(@NonNull
                                                                                  java.net.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 io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus​(@NonNull
                                                                                  io.micronaut.http.HttpRequest<?> request,
                                                                                  @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 java.lang.String getRedirectUri​(@NonNull
                                                  io.micronaut.http.HttpRequest<?> request,
                                                  @NonNull
                                                  AuthorizationErrorResponseException exception)
        Parameters:
        request - The request
        exception - The exception
        Returns:
        The URI to redirect to
      • shouldRedirect

        protected boolean shouldRedirect​(@NonNull
                                         io.micronaut.http.HttpRequest<?> request,
                                         @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