Wednesday, October 22, 2014

JavaEE with Spring Security @RolesAllowed

   @RolesAllowed({"ROLE_ADMIN"})  
   @GET  
   public User getObject(final @Context SecurityContext securityContext) {  
     User user = getUserFromSecurityContext(securityContext);  
     if(user == null) {  
       throw new UserNotFoundException();  
     }  
     return new User(user);  
   }