Class DefaultAuthorizationExceptionHandler

  • All Implemented Interfaces:
    io.micronaut.http.server.exceptions.ExceptionHandler<AuthorizationException,​io.micronaut.http.MutableHttpResponse<?>>

    @Singleton
    public class DefaultAuthorizationExceptionHandler
    extends java.lang.Object
    implements io.micronaut.http.server.exceptions.ExceptionHandler<AuthorizationException,​io.micronaut.http.MutableHttpResponse<?>>
    Provides the default behavior for responding to an AuthorizationException.
    Since:
    1.4.0
    • Constructor Detail

      • DefaultAuthorizationExceptionHandler

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

        @Deprecated
        public DefaultAuthorizationExceptionHandler​(RedirectConfiguration redirectConfiguration,
                                                    @Nullable
                                                    PriorToLoginPersistence priorToLoginPersistence)
        Deprecated.
        This will be removed in the next major version, so that this class uses the ErrorProcessor API
        Parameters:
        redirectConfiguration - Redirect configuration
        priorToLoginPersistence - Persistence mechanism to redirect to prior login url
      • DefaultAuthorizationExceptionHandler

        @Inject
        @Deprecated
        public DefaultAuthorizationExceptionHandler​(RedirectConfiguration redirectConfiguration,
                                                    RedirectService redirectService,
                                                    @Nullable
                                                    PriorToLoginPersistence priorToLoginPersistence)
        Deprecated.
        This will be removed in the next major version, so that this class uses the ErrorProcessor API
        Parameters:
        redirectConfiguration - Redirect configuration
        redirectService - Redirection Service
        priorToLoginPersistence - Persistence mechanism to redirect to prior login url
    • Method Detail

      • handle

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

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

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

        protected java.lang.String getRedirectUri​(io.micronaut.http.HttpRequest<?> request,
                                                  AuthorizationException exception)
        Parameters:
        request - The request
        exception - The exception
        Returns:
        The URI to redirect to
      • httpResponseWithStatus

        @Deprecated
        protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus​(java.net.URI location)
        Deprecated.
        This will be removed in the next major version, so that this class uses the ErrorProcessor API
        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