Results 1 to 4 of 4

Thread: Views based on roles

  1. #1
    Join Date
    Aug 2004
    Location
    Birmingham, UK
    Posts
    2

    Default Views based on roles

    Hi,

    What would be the best way to change views in spring based on the role of the authenticated user? I can't find any way to do this atm.

    Cheers

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Which MVC framework?

    If using JSP you can use the Acegi Security taglib and standard redirection. Otherwise you'll need to do it at the next layer up (eg view resolver) by obtaining the ((SecureContext) ContextHolder.getContext()).getAuthentication().

  3. #3
    Join Date
    Aug 2004
    Location
    Birmingham, UK
    Posts
    2

    Default

    I'm using Velocity, so I'd extend ResourceBundleViewResolver, which I'm currently using as my view resolver, to change the basename?

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    In your subclass you'd simply obtain the Authentication from the ContextHolder as mentioned. It should be populated properly at the time your subclass is called thanks to the Acegi Security filters. From Authentication you'd obtain the GrantedAuthority[]s and write some logic that handles redirection in your subclass. There is no current Acegi Security code which handles this.

    You could also do the same in the controller. Simply return the view name that should apply based on the GrantedAuthority[]s obtained via the ContextHolder.

    Can I ask why you're redirecting based on the view? Wouldn't a success view or a failure view for an MVC operation typically be the same, irrespective of the roles held?

Similar Threads

  1. LDAPPasswordAuthenticationDao problem
    By benoit_m35 in forum Security
    Replies: 15
    Last Post: Jan 11th, 2006, 07:04 AM
  2. Replies: 1
    Last Post: Nov 2nd, 2005, 04:43 AM
  3. Only Role Based security!!!!!!!!????????
    By sajid2045 in forum Security
    Replies: 6
    Last Post: Apr 22nd, 2005, 10:59 AM
  4. Replies: 3
    Last Post: Apr 3rd, 2005, 04:34 PM
  5. Newbie question on Pages and Views
    By ragnarwestad in forum Swing
    Replies: 8
    Last Post: Dec 13th, 2004, 10:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •