You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Hiral Matalia <Hi...@bjss.com> on 2014/06/03 11:55:05 UTC

trying to setup resource-based ACLs

Hi,

I am quite new to Jackrabbit.
I am trying to set "ALL" Privileges for the user who is creator/owner of the node.
Using Resource based ACL.
I understand that I need to have Principal for that user.
I got below code snippet

JackrabbitSession js = (JackrabbitSession) session;
        PrincipalManager pMgr = js.getPrincipalManager();
        Principal principal = pMgr.getPrincipal(user);

        AccessControlUtils.addAccessControlEntry(session,
                resNode.getPath(),
                principal,
                new String[] { Privilege.JCR_ALL },
                true);
    }

In above user is username , say testUser.
I am getting Principal as null :(
I am not sure what am I missing here, what do I need to do with PrincipalManger to get Principal for particular user who is creator/owner.

Any pointers or help is really appreciated.

Thanks !
Hiral
The information included in this email and any files transmitted with it may contain information that is confidential and it must not be used by, or its contents or attachments copied or disclosed, to persons other than the intended addressee. If you have received this email in error, please notify BJSS. In the absence of written agreement to the contrary BJSS' relevant standard terms of contract for any work to be undertaken will apply. Please carry out virus or such other checks as you consider appropriate in respect of this email. BJSS do not accept responsibility for any adverse effect upon your system or data in relation to this email or any files transmitted with it. BJSS Limited, a company registered in England and Wales (Company Number 2777575), VAT Registration Number 613295452, Registered Office Address, First Floor, Coronet House, Queen Street, Leeds, LS1 2TW

Re: trying to setup resource-based ACLs

Posted by Anuj Bhatia <an...@gmail.com>.
Hi Hiral,

If the 'user' variable has the user Id as a String, you could try the
following to get the Principal:

JackrabbitSession js = (JackrabbitSession) session;
UserManager userMgr = session.getUserManager();
Authorizable user = userMgr.getAuthorizable(userId);
Principal principal = user.getPrincipal();

You can then use the principal object with AccessControlUtils.

Hope this helps.
Anuj



On Tue, Jun 3, 2014 at 3:25 PM, Hiral Matalia <Hi...@bjss.com> wrote:
> Hi,
>
> I am quite new to Jackrabbit.
> I am trying to set "ALL" Privileges for the user who is creator/owner of the node.
> Using Resource based ACL.
> I understand that I need to have Principal for that user.
> I got below code snippet
>
> JackrabbitSession js = (JackrabbitSession) session;
>         PrincipalManager pMgr = js.getPrincipalManager();
>         Principal principal = pMgr.getPrincipal(user);
>
>         AccessControlUtils.addAccessControlEntry(session,
>                 resNode.getPath(),
>                 principal,
>                 new String[] { Privilege.JCR_ALL },
>                 true);
>     }
>
> In above user is username , say testUser.
> I am getting Principal as null :(
> I am not sure what am I missing here, what do I need to do with PrincipalManger to get Principal for particular user who is creator/owner.
>
> Any pointers or help is really appreciated.
>
> Thanks !
> Hiral
> The information included in this email and any files transmitted with it may contain information that is confidential and it must not be used by, or its contents or attachments copied or disclosed, to persons other than the intended addressee. If you have received this email in error, please notify BJSS. In the absence of written agreement to the contrary BJSS' relevant standard terms of contract for any work to be undertaken will apply. Please carry out virus or such other checks as you consider appropriate in respect of this email. BJSS do not accept responsibility for any adverse effect upon your system or data in relation to this email or any files transmitted with it. BJSS Limited, a company registered in England and Wales (Company Number 2777575), VAT Registration Number 613295452, Registered Office Address, First Floor, Coronet House, Queen Street, Leeds, LS1 2TW