samedi 14 mars 2015

@Secured and @PreAuthorize work fine in Controller but not working in Service level

What could be the problem ? When I use this annotation in my controller, it works fine, the page is only accessible for a ROLE_USER



@Secured("ROLE_USER")


This annotation works also :



@PreAuthorize("hasRole('ROLE_USER')")


When I move the same annotation to my Service, it doesn't work, the method is accessible without having the ROLE_USER role !! I'm testing Spring Security, My Service is just a test (TestService interface and its implementation), whether I put the annotation in the interface or in the implementation level, as if the annotation doesn't exist.


Thanks for helping


Aucun commentaire:

Enregistrer un commentaire