Ultimo aggiornamento il
May 03, 2021 11:35:58 AM GMT
Domanda/Sintomi
Come posso verificare se un utente ha il privilegio di eseguire una determinata azione?
Risposta / Risoluzione
Per verificare se un utente ha accesso in scrittura ad una pagina:
public boolean hasWriteAccess(Node pageNode, Session userSession) throws RepositoryException { String path = pageNode.getPath(); try { userSession.checkPermission(path, "add_node,set_property"); if(pageNode.hasNode(JcrConstants.JCR_CONTENT)) { String contentNodePath = path + "/" + "jcr:content"; userSession.checkPermission(contentNodePath, "add_node,set_property"); } } catch(java.security.AccessControlException e) { return false; } return true; }
Per verificare se un utente può attivare le pagine:
final User u = resourceResolver.adaptTo(User.class); // alternatively: final User u = SecurityUtil.resolveUser(session); return u.hasPermission(Replicator.REPLICATION_PERMISSION);
Riferimento
Prodotti interessati:
CQ5.1, CQ5.2
Accedi al tuo account