-
1. Re: Easiest way to get the Current Users's Role?
djmacpac Nov 27, 2006 8:23 AM (in response to trupoet)I'm having the same questions... ;-)
THX for your help -
3. Re: Easiest way to get the Current Users's Role?
djmacpac Nov 27, 2006 10:50 AM (in response to trupoet)That's good...but it only works with the UserName :-/
I need to find the actual RoleName... -
4. Re: Easiest way to get the Current Users's Role?
theute Nov 27, 2006 11:05 AM (in response to trupoet)It follows the J2EE security schema.
You access the principal and you can tell if the user X has role Y.
request.isUserInRole(roleName)
If you need to access the list of roles, then you need to access the user/role/membership modules. See the API -
5. Re: Easiest way to get the Current Users's Role?
djmacpac Nov 27, 2006 11:25 AM (in response to trupoet)Hmm, that's the problem:
I get the UserName viaString UserName = (String)req.getRemoteUser();
and i can get the Name viajava.security.Principal principal = req.getUserPrincipal();
Both works fine. But when I try to create a User like thisUser user = (User)userModule.findUserByUserName(UserName);
I get following Error:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:400)
... 274 more
Caused by: java.lang.ClassCastException: org.jboss.portal.identity.db.UserImpl
at $Proxy178.findUserByUserName(Unknown Source)
at TreeBacker.check_access(TreeBacker.java:99)
at TreeBacker.get_tree_rek(TreeBacker.java:143)
at TreeBacker.getTreeData(TreeBacker.java:236)
... 279 more
And I need the "User" to find his specified Role or??? -
6. Re: Easiest way to get the Current Users's Role?
bdaw Nov 27, 2006 7:20 PM (in response to trupoet)try adding portal-identity-lib.jar to your classpath
-
7. Re: Easiest way to get the Current Users's Role?
djmacpac Nov 28, 2006 2:33 AM (in response to trupoet)It is in the classpath, but it won't work :-/
Another Idea?
Perhaps it is helpfull when I say that I'm using the portal with mysql!
Do I need to work with transactions? -
8. Re: Easiest way to get the Current Users's Role?
djmacpac Nov 28, 2006 4:33 AM (in response to trupoet)OK I managed it:
I had to delete all portlet and portal libs from my lib folder in the application-war...
thx for your help guys ;-)
Have a nice day