jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1434806 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java
Date Thu, 17 Jan 2013 17:40:51 GMT
Author: angela
Date: Thu Jan 17 17:40:51 2013
New Revision: 1434806

URL: http://svn.apache.org/viewvc?rev=1434806&view=rev
Log:
OAK-51 : Implement JCR Access Control Management: Add more utility methods to AccessControlUtils

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java?rev=1434806&r1=1434805&r2=1434806&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/authorization/AccessControlUtils.java
Thu Jan 17 17:40:51 2013
@@ -102,9 +102,27 @@ public class AccessControlUtils {
      */
     public static JackrabbitAccessControlList getAccessControlList(Session session, String
absPath) throws RepositoryException {
         AccessControlManager acMgr = session.getAccessControlManager();
+        return getAccessControlList(acMgr, absPath);
+    }
 
+    /**
+     * Utility that combines {@link AccessControlManager#getApplicablePolicies(String)}
+     * and {@link AccessControlManager#getPolicies(String)} to retrieve
+     * a modifiable {@code JackrabbitAccessControlList} for the given path.<br>
+     *
+     * Note that the policy must be {@link AccessControlManager#setPolicy(String,
+     * javax.jcr.security.AccessControlPolicy) reapplied}
+     * and the changes must be saved in order to make the AC modifications take
+     * effect.
+     *
+     * @param accessControlManager The {@code AccessControlManager} .
+     * @param absPath The absolute path of the target node.
+     * @return A modifiable access control list or null if there is none.
+     * @throws RepositoryException If an error occurs.
+     */
+    public static JackrabbitAccessControlList getAccessControlList(AccessControlManager accessControlManager,
String absPath) throws RepositoryException {
         // try applicable (new) ACLs
-        AccessControlPolicyIterator itr = acMgr.getApplicablePolicies(absPath);
+        AccessControlPolicyIterator itr = accessControlManager.getApplicablePolicies(absPath);
         while (itr.hasNext()) {
             AccessControlPolicy policy = itr.nextAccessControlPolicy();
             if (policy instanceof JackrabbitAccessControlList) {
@@ -113,7 +131,7 @@ public class AccessControlUtils {
         }
 
         // try if there is an acl that has been set before
-        AccessControlPolicy[] pcls = acMgr.getPolicies(absPath);
+        AccessControlPolicy[] pcls = accessControlManager.getPolicies(absPath);
         for (AccessControlPolicy policy : pcls) {
             if (policy instanceof JackrabbitAccessControlList) {
                 return (JackrabbitAccessControlList) policy;



Mime
View raw message