-
1. Re: user's group
theute Jun 18, 2007 6:42 AM (in response to maiky)You can't get the roles of a user, you can only check if the user is in a specific role.
-
2. Re: user's group
bvogt Jun 18, 2007 6:55 AM (in response to maiky)I've posted a solution, please take a look at:
http://jira.jboss.org/jira/browse/JBPORTAL-1293 -
3. Re: user's group
maiky Jun 18, 2007 7:12 AM (in response to maiky)You can't get the roles of a user, you can only check if the user is in a specific role.
What must I do to check the role ?
Thanks
PS: Sorry for my bad English -
4. Re: user's group
theute Jun 18, 2007 7:46 AM (in response to maiky)
Use:
isUserInRole(String toto)
See the portlet spec -
5. Re: user's group
maiky Jul 4, 2007 7:17 AM (in response to maiky)I'm back !
I find the methods to get an user when I'm in a page but they return null any time.
I'm use :
User user = (User) request.getAttribute("org.jboss.portal.header.USER");
in library org.jboss.portal.identity.User
What I must do ?
After, I don't find the method isUserInRole(String toto) :( what is the class at this method ?
Thanks.
PS: Sorry for my bad English. -
6. Re: user's group
theute Jul 4, 2007 7:31 AM (in response to maiky)isUserInRole is on renderRequest or actionRequest:
See:
http://docs.jboss.org/jbportal/spec/docs/javax/portlet/PortletRequest.html
You can also use
getRemoteUser() on the same object to get the id of the llogged-in user. -
-
8. Re: user's group
maiky Jul 4, 2007 8:13 AM (in response to maiky)Thks for the methods I can get the user who is connect.
But I've a last little problem :
The isUserInRole("role") return me false any time.
I check with many role's name (I create an user with all roles), I try with the Users or the Administrators.
No error in return just false.
I read that it can be provide that not have user authenticated, but I sure it is.
The page where the method is, need authentificated and I can get the user name in the same place.
Sorry if I'm annoying.
Thanks.
PS: Sorry for my bad English. -
9. Re: user's group
brownfielda Jul 4, 2007 8:25 AM (in response to maiky)Two things tripped me up when I was starting on this. First make sure to put the security-role-ref stuff into your portlet.xml. You can find the details about this in the section 20.3 of the portlet spec.
Also, make sure to use the actual role names, not the displayed ones. The defaults are Admin and User. If you ever get confused about these again and you have access to the underlying database, spit out the contents of the jbp_roles table. -
10. Re: user's group
maiky Jul 4, 2007 8:59 AM (in response to maiky)First of all, thks for the help, I must get the role of user for finalize my portlet for Friday, and it's reassure me to find a community who try to help.
But, the problem persist...
I check the database and I'm sure now I use the role names.
I try with Admin or User for test (with a user that is in all roles)
return false.
I add<security-role-ref> <role-name>Admin</role-name> </security-role-ref>
in my portlet.xml
I log in admin and try and return false.
I despair :(
PS: Sorry for my bad English.