SLING-7835 PrivilegesInfo#getEffectiveAccessControlEntries returns
authorEric Norman <enorman@apache.org>
Sun, 19 Aug 2018 20:22:39 +0000 (13:22 -0700)
committerEric Norman <enorman@apache.org>
Sun, 19 Aug 2018 20:22:39 +0000 (13:22 -0700)
incorrect information

src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java

index d0e0133..0232e2f 100644 (file)
 package org.apache.sling.jcr.jackrabbit.accessmanager;
 
 import java.security.Principal;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
@@ -178,13 +180,17 @@ public class PrivilegesInfo {
        private AccessControlEntry[] getDeclaredAccessControlEntries(Session session, String absPath) throws RepositoryException {
                AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
                AccessControlPolicy[] policies = accessControlManager.getPolicies(absPath);
-               for (AccessControlPolicy accessControlPolicy : policies) {
-                       if (accessControlPolicy instanceof AccessControlList) {
-                               AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
-                               return accessControlEntries;
-                       }
-               }
-               return new AccessControlEntry[0];
+               
+        List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>(); 
+        for (AccessControlPolicy accessControlPolicy : policies) {
+            if (accessControlPolicy instanceof AccessControlList) {
+                AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
+                for (AccessControlEntry accessControlEntry : accessControlEntries) {
+                                       allEntries.add(accessControlEntry);
+                               }
+            }
+        }
+        return allEntries.toArray(new AccessControlEntry[allEntries.size()]);
        }
 
        /**
@@ -286,13 +292,17 @@ public class PrivilegesInfo {
        private AccessControlEntry[] getEffectiveAccessControlEntries(Session session, String absPath) throws RepositoryException {
                AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
                AccessControlPolicy[] policies = accessControlManager.getEffectivePolicies(absPath);
-               for (AccessControlPolicy accessControlPolicy : policies) {
-                       if (accessControlPolicy instanceof AccessControlList) {
-                               AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
-                               return accessControlEntries;
-                       }
-               }
-               return new AccessControlEntry[0];
+               
+        List<AccessControlEntry> allEntries = new ArrayList<AccessControlEntry>(); 
+        for (AccessControlPolicy accessControlPolicy : policies) {
+            if (accessControlPolicy instanceof AccessControlList) {
+                AccessControlEntry[] accessControlEntries = ((AccessControlList)accessControlPolicy).getAccessControlEntries();
+                for (AccessControlEntry accessControlEntry : accessControlEntries) {
+                                       allEntries.add(accessControlEntry);
+                               }
+            }
+        }
+        return allEntries.toArray(new AccessControlEntry[allEntries.size()]);
        }
 
        /**