Security in Jcr singleton.
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 27 Oct 2019 09:02:19 +0000 (10:02 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 27 Oct 2019 09:02:19 +0000 (10:02 +0100)
org.argeo.jcr/src/org/argeo/jcr/Jcr.java

index 608f897365f112df382cf05d94a8887840d78980..43e47dacad11512df281923caca5ae37e5bea9dc 100644 (file)
@@ -14,6 +14,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.security.Privilege;
 import javax.jcr.version.Version;
 import javax.jcr.version.VersionHistory;
 import javax.jcr.version.VersionIterator;
@@ -337,6 +338,23 @@ public class Jcr {
                }
        }
 
+       /*
+        * SECURITY
+        */
+       /**
+        * Add a single privilege to a node.
+        * 
+        * @see Privilege
+        */
+       public static void addPrivilege(Node node, String principal, String privilege) {
+               try {
+                       Session session = node.getSession();
+                       JcrUtils.addPrivilege(session, node.getPath(), principal, privilege);
+               } catch (RepositoryException e) {
+                       throw new IllegalStateException("Cannot add privilege " + privilege + " to " + node, e);
+               }
+       }
+
        /*
         * VERSIONING
         */