Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create new spring annotation

I'm developing an application in Spring which has numerous methods in the controller, and are mapped to various URL using @RequestMapping.

Some of these methods (and hence url) are accessible to some user roles, and not to others. Can I create annotations, and annotate these methods so that only privileged users have access to right methods, while not to the others?

Thanks in advance.

like image 710
James Avatar asked Oct 12 '22 09:10

James


2 Answers

I am not sure if creating new annotations is what you really need. You could probably use Spring Security and its annotations. Please take a look here to see if it is what you are looking for.

like image 169
Paweł Dyda Avatar answered Oct 26 '22 23:10

Paweł Dyda


You can use Spring Security and its annotations, restrict access to some methods. This Blog post show some features of annotations used with Spring Security 3.

Have a look at this question and answer, to see how you build your own annotations on top of spring security.

See also the documentation of Spring Security 3.1, Chapter Expression-Based Access Control.

like image 21
Ralph Avatar answered Oct 27 '22 00:10

Ralph