Guest User

Untitled

a guest
Oct 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. @Retention(RetentionPolicy.RUNTIME)
  2. @Inherited
  3. @Documented
  4. @PreAuthorize(AllowedForSystemUsers.condition)
  5. public @interface AllowedForSystemUsers {
  6. String condition = "hasAnyRole({'ROLE_ADMIN', 'ROLE_USER'})";
  7. }
  8.  
  9. @RequestMapping(value="/search", method=RequestMethod.POST)
  10. @AllowedForSystemUsers
  11. public String searchRooms(@ModelAttribute Booking booking, Model model, long type) {
  12.  
  13. //do something
  14. }
  15.  
  16. @ExceptionHandler(value = AccessDeniedException.class)
  17. public ModelAndView accessDenied(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) {
  18.  
  19. return new ModelAndView("redirect:/error");
  20. }
Add Comment
Please, Sign In to add comment