Class DefaultAuthorizationExceptionHandler
- java.lang.Object
-
- io.micronaut.security.authentication.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 anAuthorizationException.- Since:
- 1.4.0
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthorizationExceptionHandler()Default constructor.DefaultAuthorizationExceptionHandler(RedirectConfiguration redirectConfiguration, PriorToLoginPersistence priorToLoginPersistence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringgetRedirectUri(io.micronaut.http.HttpRequest<?> request, AuthorizationException exception)io.micronaut.http.MutableHttpResponse<?>handle(io.micronaut.http.HttpRequest request, AuthorizationException exception)protected io.micronaut.http.MutableHttpResponse<?>httpResponseWithStatus(io.micronaut.http.HttpRequest<?> request, AuthorizationException exception)protected io.micronaut.http.MutableHttpResponse<?>httpResponseWithStatus(java.net.URI location)Builds a HTTP Response redirection to the supplied location.protected booleanshouldRedirect(io.micronaut.http.HttpRequest<?> request, AuthorizationException exception)Decides whether the request should be handled with a redirect.
-
-
-
Constructor Detail
-
DefaultAuthorizationExceptionHandler
public DefaultAuthorizationExceptionHandler()
Default constructor.
-
DefaultAuthorizationExceptionHandler
@Inject public DefaultAuthorizationExceptionHandler(RedirectConfiguration redirectConfiguration, @Nullable PriorToLoginPersistence priorToLoginPersistence)
- Parameters:
redirectConfiguration- Redirect configurationpriorToLoginPersistence- 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:
handlein interfaceio.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 requestexception- 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 Requestexception- 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 requestexception- The exception- Returns:
- The URI to redirect to
-
httpResponseWithStatus
protected io.micronaut.http.MutableHttpResponse<?> httpResponseWithStatus(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
-
-