title: How can I automate applying permissions for a JCR node?
body: <p>For the CQ5 environment I work on we have a farm of publisher servers.  Some of the content on these servers is restricted so only users who belong to certain groups can see the content.  I'd like to script the setting of permissions for the folders (nodes) that are to be secured so I don't have to manually repeat the steps of applying security using the Access Control Editor of Content Explorer (<a href="http://helpx.adobe.com/cq/kb/CQ53ACLsMappingToCRX2.html" rel="nofollow">This Adobe documentation</a> has instructions for doing it manually via Access Control Editor).  The scenario is that sometimes new folders are to be created to hold secure pages, and we want to apply permissions to the folders prior to activating any content into those folders.</p>
  
  <p>Since the environment has several publishers, it is repetitive, manual, and error-prone work to open Content Explorer and set the permissions on each one.  I'd like to do be able to automate this so I could roll out permissions to all the servers via a script--perhaps via a curl command or some other mechanism (perhaps a package?) that can be automated.</p>
  
  <p>I found the <a href="http://sling.apache.org/site/managing-permissions-jackrabbitaccessmanager.html" rel="nofollow">Sling jackrabbit-accessmanager bundle</a> that seems like it will facilitate automation of this, but it seems like it opens a security hole.  If I put this bundle on my publishers, it seems like I would be providing an REST interface to let anyone modify the permissions and grant access to folders/nodes that should be secured or to add security restrictions on nodes that should have none.</p>
  
  <p>How can I automate the creation/modification of node permissions via a script--and do so in a way that only allows an administrator to apply the permissions changes?</p>