0

Hi i am new to Spring and I have a following problem:

I had succesfully implemented login mechanism on my website, but I know how to make it work only on specified subpages by:

  <http entry-point-ref="authenticationEntryPoint" auto-config="true">
    <intercept-url pattern="/admin" access="ROLE_ADMIN" /> 

And I would like to hide only choosen elements on subpages that are visible for any user.

For example anyone can acces a subpage to read an article on my website, but only registered user can add a comment.

user1431729
  • 144
  • 6

1 Answers1

1

you may want to use <sec:global-method-security pre-post-annotations="enabled"/> in your web context, so that you can use that annotation @PreAuthorize("hasRole('YOUR ROLE')") in your controller.

Than you can user the spring-security tags to show/hide content on your jsp page depending on the connected user role.

you can have more docs here http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity.html

storm_buster
  • 7,362
  • 18
  • 53
  • 75
  • Thank you very much :) Documentation part that I needed http://static.springsource.org/spring-security/site/docs/3.1.x/reference/taglibs.html – user1431729 Jun 21 '12 at 22:35