jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rohit mittal <rohit78...@gmail.com>
Subject Re: Set the permission(read/write/all) on a node
Date Fri, 16 Oct 2009 06:08:51 GMT
Hi users,

I have used this configuration for access manager in repository.xml

    <AccessManager
class="org.apache.jackrabbit.core.security.DefaultAccessManager">
           <!--  <param name="config" value="${rep.home}/access.xml"/>
-->

        </AccessManager>


    AccessControlManager acManager = sessionImpl.getAccessControlManager();
    AccessControlPolicy acPolicy = null;
    AccessControlList acl = null;
    String nodePath = folderNode.getPath();
    AccessControlPolicyIterator policyIterator =
acManager.getApplicablePolicies(nodePath);
    if (policyIterator.hasNext())
    {
        acPolicy = policyIterator.nextAccessControlPolicy();
    }
    else
    {
        AccessControlPolicy[] existingPolicies =
acManager.getPolicies(nodePath);
        acPolicy = existingPolicies[0];
    }
    if (acPolicy instanceof AccessControlList)
    {
        acl = (AccessControlList) acPolicy;
        Privilege[] privileges = {
acManager.privilegeFromName(Privilege.JCR_ALL) };
        Principal p_myUser = new PrincipalImpl("user1");
        boolean flag = acl.addAccessControlEntry(p_myUser, privileges);
        System.out.println("..........................." + flag);
        acManager.setPolicy(nodePath, acl);
        sessionImpl.save();
        session.save();
    }

   In this code
   acl.addAccessControlEntry(p_myUser, privileges);  always return false for
when i login to user and its return true only for when i login to admin.
   So privilege are not setting for user. So how can i do?

   *Thanks
   Rohit Mittal*





On Thu, Oct 15, 2009 at 8:36 PM, Angela Schreiber <anchela@day.com> wrote:

> hi rohit
>
> as far as i know the SimpleAccessManager doesn't support
> access control editing.
>
> regards
> angela
>
>
>
>  I have a problem regarding to set the permission(read/write/all) on a node
>> for a user. In my user configuration ,I
>> place users in different directories on a single workspace.
>>
>> The configuration for access manager in repository.xml is as follows:
>>
>>  <AccessManager
>> class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
>>     <!--  <param name="config" value="${rep.home}/access.xml"/>       -->
>>  </AccessManager>
>>
>>  To set the policy for a user("user1") , i am using following code-
>>
>> AccessControlManager accessControlManager =
>> sessionImpl.getAccessControlManager();
>> String restrictedArea = folderNode.getPath();
>> AccessControlPolicy[] restrictedPolicies =
>> accessControlManager.getPolicies(restrictedArea);
>> JackrabbitAccessControlList restrictedPolicy
>> =(JackrabbitAccessControlList)
>> restrictedPolicies.nextAccessControlPolicy();
>> Privilege[] privileges = {
>> accessControlManager.privilegeFromName(Privilege.JCR_READ) };
>> Principal p_myUser = new PrincipalImpl("user1");
>> restrictedPolicy.addEntry(p_myUser, privileges, true);
>> accessControlManager.setPolicy(restrictedArea, restrictedPolicy);
>> sessionImpl.save();
>>
>>  Please tell me , How to set the permission on a node ?
>>
>> Thanks
>> Rohit Mittal
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message