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 Summary
ConstructorDescriptionAuthorizationErrorResponseExceptionHandler
(RedirectConfiguration redirectConfiguration, RedirectService redirectService, io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> errorResponseProcessor) -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull String
getRedirectUri
(@NonNull io.micronaut.http.HttpRequest<?> request, @NonNull AuthorizationErrorResponseException exception) io.micronaut.http.MutableHttpResponse<?>
handle
(io.micronaut.http.HttpRequest request, AuthorizationErrorResponseException exception) protected @NonNull io.micronaut.http.MutableHttpResponse<?>
httpResponseWithStatus
(@NonNull io.micronaut.http.HttpRequest<?> request, @NonNull AuthorizationErrorResponseException exception) protected @NonNull io.micronaut.http.MutableHttpResponse<?>
httpResponseWithStatus
(@NonNull URI location) Builds a HTTP Response redirection to the supplied location.protected boolean
shouldRedirect
(@NonNull io.micronaut.http.HttpRequest<?> request, @NonNull AuthorizationErrorResponseException exception) Decides whether the request should be handled with a redirect.
-
Constructor Details
-
AuthorizationErrorResponseExceptionHandler
public AuthorizationErrorResponseExceptionHandler(RedirectConfiguration redirectConfiguration, RedirectService redirectService, io.micronaut.http.server.exceptions.response.ErrorResponseProcessor<?> errorResponseProcessor) - Parameters:
redirectConfiguration
- Redirect ConfigurationredirectService
- Redirect ServiceerrorResponseProcessor
- Error Response Processor
-
-
Method Details
-
handle
public io.micronaut.http.MutableHttpResponse<?> handle(io.micronaut.http.HttpRequest request, AuthorizationErrorResponseException exception) - Specified by:
handle
in interfaceio.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 requestexception
- 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 requestexception
- 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 Requestexception
- The authorization exception- Returns:
- true if the request accepts text/html
-