You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by husbas <hu...@gmail.com> on 2011/06/05 12:46:54 UTC

Being an Admin how to check user permission

Being logged in a Admin, how can I check whether a user has access to a node
or not?
something like 

session.hasPermissions(String nodePath, String actions, String asUser);



--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Being-an-Admin-how-to-check-user-permission-tp3574834p3574834.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Re: Being an Admin how to check user permission

Posted by François Cassistat <f....@maya-systems.com>.
There may be a better way, but you could try using Session.impersonate(...) with the user you want to test.

I'm not sure if it is fast, though.


F!


Le 2011-06-05 à 6:46 AM, husbas a écrit :

> Being logged in a Admin, how can I check whether a user has access to a node
> or not?
> something like 
> 
> session.hasPermissions(String nodePath, String actions, String asUser);
> 
> 
> 
> --
> View this message in context: http://jackrabbit.510166.n4.nabble.com/Being-an-Admin-how-to-check-user-permission-tp3574834p3574834.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: Being an Admin how to check user permission

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 06.06.11 17:34, "Charles Brooking"
<pu...@charlie.brooking.id.au> wrote:
>My understanding is that there's some new, "native" support for users
>and access management in JCR/Jackrabbit 2, so others on the list can
>probably offer updated advice.

Yes, since JCR 2.0, access control is part of the specification.

http://wiki.apache.org/jackrabbit/AccessControl

Regards,
Alex

-- 
Alexander Klimetschek
Developer // Adobe (Day) // Berlin - Basel





Re: Being an Admin how to check user permission

Posted by Charles Brooking <pu...@charlie.brooking.id.au>.
On 05/06/11 20:46, husbas wrote:
> Being logged in a Admin, how can I check whether a user has access to a node
> or not? something like
>
> session.hasPermissions(String nodePath, String actions, String asUser);

This is a good question.

I achieved this a while ago - with Jackrabbit 1.5, in 2009 - by creating 
a CustomAccessPolicy class with domain/application-specific methods like 
canReadProject(String path), canCreateGroup(), etc. This class tested 
each permission using javax.jcr.Session.checkPermission(String path, 
String actions) for a user-specific session object instantiated for each 
request.

In Jackrabbit 1.5 at least, you would write your own AccessManager by 
implementing org.apache.jackrabbit.core.security.AccessManager. In my 
case, this access manager looked at ordinary nodes/properties in the 
workspace to decide permissions (eg checking whether 
/users/joe.getUUID() in /projects/abc/@readers.getValues()).

My understanding is that there's some new, "native" support for users 
and access management in JCR/Jackrabbit 2, so others on the list can 
probably offer updated advice.

Later
Charlie