Results 1 to 10 of 10

Thread: different role using different home page

  1. #1
    Join Date
    Apr 2007
    Location
    Montreal, Canada
    Posts
    31

    Default different role using different home page

    Hi,
    I want to different role has different homepage.
    When a user logins successfully, it will use defaultTargetUrl as homepage.
    <property name="defaultTargetUrl" value="/home.spring" />
    .....
    <prop key="/home.spring">homeController</prop>
    ...
    I will add some logic in homeController to check role, then forward to different homepage.

    Is it a good way to support this requirement?

    Thanks a lot.
    Arden

  2. #2
    Join Date
    Apr 2007
    Location
    Montreal, Canada
    Posts
    31

    Default

    how could I get role information in my controller?
    Thanks

  3. #3
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    You can lookup the Authentication details using SecurityContextHolder.getContext().getAuthenticati on(). All you need to do then is apply your check.

  4. #4
    Join Date
    Apr 2007
    Location
    Montreal, Canada
    Posts
    31

    Default

    Quote Originally Posted by karldmoore View Post
    You can lookup the Authentication details using SecurityContextHolder.getContext().getAuthenticati on(). All you need to do then is apply your check.
    Which function I could get role information?

    public interface Authentication
    extends Principal, Serializable
    {

    public abstract GrantedAuthority[] getAuthorities();

    public abstract Object getCredentials();

    public abstract Object getDetails();

    public abstract Object getPrincipal();

    public abstract boolean isAuthenticated();

    public abstract void setAuthenticated(boolean flag)
    throws IllegalArgumentException;
    }

  5. #5
    Join Date
    May 2007
    Posts
    2

    Default

    public abstract GrantedAuthority[] getAuthorities();

    this one may help

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote Originally Posted by gbsgbsgbs View Post
    public abstract GrantedAuthority[] getAuthorities();
    Yes indeed, that's the one I was thinking of.

  7. #7
    Join Date
    Apr 2007
    Location
    Montreal, Canada
    Posts
    31

    Default

    Thanks a lot.

  8. #8
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Not a problem, glad the information was useful. Did you get all of this working then?

  9. #9
    Join Date
    Apr 2007
    Location
    Montreal, Canada
    Posts
    31

    Default

    Quote Originally Posted by karldmoore View Post
    Not a problem, glad the information was useful. Did you get all of this working then?
    after I check role name in my homeController, I try to forward to different controller, but I do not know how to do it.
    Now, in my homeController, I could only return different view.
    http://forum.springframework.org/showthread.php?t=38846

  10. #10
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Ok, I'll got an have a look at that thead.

Posting Permissions

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