Author | Message |
---|---|
abhishek_sharma
Posts: 79
|
Posted 17:37 Aug 16, 2012 |
I am using Spring version 3.1 in this new setup, trying to follow CSNS2 architect. Everything is running fine but I can't able to use hadRole('ROLE_USER') or any, it's not working at all. So I copied all files necessary file from CSNS2. I can able to login display User information but only hasRole(*) is not working. If anyone knows if I am missing any configuation. Thanks
|
cysun
Posts: 2935
|
Posted 20:16 Aug 16, 2012 |
You probably didn't specify |
abhishek_sharma
Posts: 79
|
Posted 22:19 Aug 16, 2012 |
I did specify it. I remember from class video, either we can use default or can customize . So, following CSNS2 I do have user and role classes. My roles table having name like 'ROLE_USER' , I noticed in csns.roles table it is 'ROLE USER', is there any place I need to configure it? I can login successfully and can display property.<any property name> to debug I want display property.roles, is any way I can display it. Something like this (I know it's wrong syntax, but just to clear my point and debug) <c: foreach items='<security:authentication property="principal.firstName"/>' var="role"> ${role.name) </c:foreach> |
cysun
Posts: 2935
|
Posted 08:49 Aug 17, 2012 |
I believe the <authentication> tag only displays information, i.e. you can't assign a property as an object to another tag. You can however access the Authentication object in your controller then pass whatever you what to display to the view. See SecurityUtils in CSNS2 for how to access the Authentication object, and see the documentation for what's in it (the roles are called "authorities"). |
abhishek_sharma
Posts: 79
|
Posted 16:41 Aug 17, 2012 |
Solved.. Sorry I asked a question, but then I got it worked and since can't delete post so writing this.
Thanks Last edited by abhishek_sharma at
16:54 Aug 17, 2012.
|