We use cookies to serve our customers and website visitors in the best possible way. Cookies are used for the proper functioning of the website and for improving the user experience, monitoring visitor traffic and marketing purposes. By continuing to browse the site, you agree to our use of cookies. You can read more about cookies here.
com.vaadin.flow.server.auth.
Package com.vaadin.flow.server.auth
Annotation Interface AccessDeniedErrorRouter
Annotation for customizing route specific rerouting of access denied error in
AnnotatedViewAccessChecker
. Annotation is to be used together with
@Route
, or if present, together with access annotation listed here:
@AnonymousAllowed
@PermitAll
@RolesAllowed
@DenyAll
@AccessDeniedErrorRouter(rerouteToError = CustomAccessDeniedException.class) @RolesAllowed("admin") @Route("test") public class TestView extends Div { } @AccessDeniedErrorRouter(rerouteToError = CustomAccessDeniedException.class) @RolesAllowed("admin") public class ParentView extends Div { } @Route("subview") public class SubView extends ParentView { } public class CustomAccessDeniedException extends RuntimeException { } @Tag(Tag.DIV) public class CustomAccessDeniedError implementsHasErrorParameter<CustomAccessDeniedException>
{ @Override public int setErrorParameter(BeforeEnterEvent event,ErrorParameter<CustomAccessDeniedException>
parameter) { getElement().setText("Access denied."); return HttpStatusCode.UNAUTHORIZED.getCode(); } }
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends RuntimeException>
Reroute access denied error by the given exception.
-
Element Details
-
rerouteToError
Class<? extends RuntimeException> rerouteToErrorReroute access denied error by the given exception. Exception is
AccessDeniedException
by default. It can be changed to other exception likeNotFoundException
or any other exception mapped toHasErrorParameter
error view.Returns:
Type of the access denied exception for the access denied error view.
Default:
com.vaadin.flow.router.AccessDeniedException.class
-