Class RedirectRejectionHandler

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.util.Optional<java.lang.String> getRedirectUri​(io.micronaut.http.HttpRequest<?> request, boolean forbidden)
      Returns the redirection uri.
      protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithUri​(java.lang.String uri)
      Builds a HTTP Response redirection to the supplied location.
      protected io.micronaut.http.HttpStatus redirectionHttpStatus()  
      org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> reject​(io.micronaut.http.HttpRequest<?> request, boolean forbidden)
      Handles rejection of a request.
      protected boolean shouldHandleRequest​(io.micronaut.http.HttpRequest<?> request)
      Decides whether the request should be handled with a redirect.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RedirectRejectionHandler

        public RedirectRejectionHandler​(UnauthorizedRejectionUriProvider unauthorizedRejectionUriProvider,
                                        ForbiddenRejectionUriProvider forbiddenRejectionUriProvider,
                                        RedirectRejectionHandlerConfiguration redirectRejectionHandlerConfiguration)
        Constructor.
        Parameters:
        unauthorizedRejectionUriProvider - URI Provider to redirect to if unauthenticated
        forbiddenRejectionUriProvider - URI Provider to redirect to if authenticated but not enough authorization level.
        redirectRejectionHandlerConfiguration - Redirect Rejection Handler Configuration
    • Method Detail

      • reject

        public org.reactivestreams.Publisher<io.micronaut.http.MutableHttpResponse<?>> reject​(io.micronaut.http.HttpRequest<?> request,
                                                                                              boolean forbidden)
        Handles rejection of a request.
        Specified by:
        reject in interface RejectionHandler
        Parameters:
        request - HttpRequest being processed
        forbidden - if true indicates that although the user was authenticated he did not had the necessary access privileges.
        Returns:
      • shouldHandleRequest

        protected boolean shouldHandleRequest​(io.micronaut.http.HttpRequest<?> request)
        Decides whether the request should be handled with a redirect.
        Parameters:
        request - The HTTP Request
        Returns:
        true if the request accepts text/html
      • httpResponseWithUri

        protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithUri​(java.lang.String uri)
                                                                        throws java.net.URISyntaxException
        Builds a HTTP Response redirection to the supplied location.
        Parameters:
        uri - The Uri to redirect to
        Returns:
        a 303 HTTP response with the Uri as location
        Throws:
        java.net.URISyntaxException - if the supplied uri String cannot be used with URI.
      • redirectionHttpStatus

        protected io.micronaut.http.HttpStatus redirectionHttpStatus()
        Returns:
        return the Http status code which will be used for the redirection
      • getRedirectUri

        protected java.util.Optional<java.lang.String> getRedirectUri​(io.micronaut.http.HttpRequest<?> request,
                                                                      boolean forbidden)
        Returns the redirection uri.
        Parameters:
        request - HttpRequest being processed
        forbidden - if true indicates that although the user was authenticated he did not had the necessary access privileges.
        Returns:
        the uri to redirect to