How to programmatically set permission to a single path(node) to a given user? | Community
Skip to main content
Employee
Oct 16, 2015 2:28 AM UTC
Solved

How to programmatically set permission to a single path(node) to a given user?

In our process we create nodes for binary files. Meanwhile, the node path could be emailed to a CQ user to access and download the file later. I'd like to know if its possible to grand the node read permission to this CQ user programmatically.

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:28 AM UTC

4 replies

Employee
Oct 16, 2015 2:28 AM UTC

Thanks both for the info! I've got my problem resolved. I found out that this site is very helpful as well: http://wiki.apache.org/jackrabbit/AccessControl

Translate
Sham_HC
Sham_HCAccepted solution
Level 10
Oct 16, 2015 2:28 AM UTC
srikanthp689160
Level 4
Sep 21, 2020 11:26 AM UTC
Hi Unable to set ACL permission for nodes under "/content" but its working for nodes under "/apps" Our Project requirement is to create User Group and assign Permissions Programmatically. Created a Postprocessor to get the SAML Response and based on that Creating group and permissions programmatically. While applying permissions to the newly created group, for the paths which are available in "/content" permission  are not getting applied but for "/apps" and "/var" permissions are getting applied.   private void parseSAMLResponse(Set<String> runModes, String samlResponseString)throws ParserConfigurationException, SAXException, IOException, UnsupportedEncodingException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder(); Map<String, String> samlAttributeMap = new HashMap<String, String>(); StringReader strReader = new StringReader(samlResponseString); InputSource inputSource = new InputSource(strReader); Document document = docBuilder.parse(inputSource); NodeList samlAssertion = document.getElementsByTagName("saml:Assertion"); populateSAMLAttrMap(samlAttributeMap, samlAssertion); String userType = samlAttributeMap.get("Display Name") ; String userRole = samlAttributeMap.get("Given Name") ; String brandCode = samlAttributeMap.get("Surname") ; String dealerId = samlAttributeMap.get("Sign in name") ; log.info("Attributes ::::"+userType+"........."+userRole+".........."+brandCode+"........"+dealerId); try { final UserManager userManager = ((JackrabbitSession) session).getUserManager(); Group group = null; if (userManager.getAuthorizable(userRole) == null) { group = userManager.createGroup(userRole); ValueFactory valueFactory = session.getValueFactory(); Value groupNameValue = valueFactory.createValue(userRole, PropertyType.STRING); group.setProperty("./profile/givenName", groupNameValue); log.info("path of the group"+ group.getPath() +"principal of the group"+ group.getPrincipal()+ group.getID()); String groupPath = "/apps/POC_SSO"; log.info("---> {} Group successfully created.", group.getID()); setReadPermissions(group, groupPath, session); setDeletePermissions(group, groupPath, session); setModifyPermissions(group, groupPath, session); setCreatePermissions(group, groupPath, session); setReplicatePermissions(group, groupPath, session); setReadACLPermissions(group, groupPath, session); setEditACLPermissions(group, groupPath, session); group.addMember(auth); log.info("---> {} User added successfully.", group.getMembers()); } else { log.info("---> Group already exist.."); } session.save(); } catch (Exception e) { log.info("---> Exception.." + e.getMessage()); } }
Translate
New Participant
Oct 16, 2015 2:28 AM UTC