Custom RolesAllowed like annotation

Hello, I’d to ask how to create an annotation that can be seen by Vaadin. I have created an Annotation called CustomRolesAllowed that is annotated with PreAuthorize. However, this annotation only works if annotated with @PermitAll and without it I get the error. How can I make this CustomRolesAllowed to work by itself

I am getting the following error:
Reason: Consider adding one of the following annotations to make the view accessible: AnonymousAllowed, PermitAll, RolesAllowed.

Create your own AccessAnnotationChecker so that the framework can pick it up and use it

You cannot use Spring Security annotations. Only the listed ones

Annotations do not work by themselves alone as they are just markers, that require some logic somewhere in your application that is able to read the annotations from the class and then do something.

For example I have a vanilla Vaadin 8 demo application here (no Spring or anything), I define custom annotation like

I set global before view change listener (equivalent to global beforeEnter in Flow) vaadin-create23/vaadincreate-ui/src/main/java/org/vaadin/tatu/vaadincreate/AppLayout.java at master · TatuLund/vaadin-create23 · GitHub

And then I read the annotation from the target class of the navigation and do things accordingly

This is not Vaadin specific thing, but how Java language works with annotations.

Some frameworks, especially Spring, contain huge amount of this kind of logic behind the annotations, and that is what makes Spring work.