You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:48:04 UTC
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] annotated tag
org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0 created (now 16e383f)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git.
at 16e383f (tag)
tagging 428139408750aa4822cfc9064709ea3579b10807 (commit)
by Justin Edelson
on Wed Nov 3 17:52:48 2010 +0000
- Log -----------------------------------------------------------------
org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
-----------------------------------------------------------------------
This annotated tag includes the following new commits:
new d3f7b97 Import jackrabbit-accessmanager
new 6e7aae9 SLING-879: New Bundle to provide actions for interacting with the jackrabbit AccessManager. Patch provided by Eric Norman. https://issues.apache.org/jira/browse/SLING-879
new 1431cb1 SLING-941: Lots of svn:eol-style settings missing
new 1ab84c7 SLING-941: Lots of svn:eol-style settings missing
new 8c19a30 SLING-941: Lots of svn:eol-style settings missing
new d78f209 Use released version of jackrabbit api
new 067e7fc Use jackrabbit api bundle instead of Sling's obsolete version.
new ab58792 Use release parent pom
new f64de42 Use released version as dependencies.
new 258a10d [maven-release-plugin] prepare release org.apache.sling.jcr.jackrabbit.accessmanager-2.0.0-incubator
new 70bb409 [maven-release-plugin] prepare for next development iteration
new 9f5f16d Use next dev version of parent pom
new 8101ae1 Add license header
new c1777c5 Add missing licence, notice etc.
new 3b447fa Prepare new release.
new 995d0e6 [maven-release-plugin] prepare release org.apache.sling.jcr.jackrabbit.accessmanager-2.0.2-incubator
new 3c7b087 [maven-release-plugin] prepare for next development iteration
new c4e0670 Use next parent pom for development.
new d627e7e Set parent pom to released version.
new a8d22a3 Move Sling to new TLP location
new 94aca6e SLING-1011 : Remove disclaimer file.
new 6bbebdf SLING-1011 : Adjust svn location
new 6d9578b SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
new 6390829 SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
new 4a672c9 SLING-940 Applied patch from myself. Adds Javadoc to accessmanager and usermanager servlets.
new 5f5f49d Use official release instead of incubator release.
new 5fd0e3b Update to latest Sling releases.
new 0e2d9a5 SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
new 32c555a SLING-1208 Adapt to an API change between Jackrabbit 1.5 and 1.6: If a node as a access control policy set, the AccessControlManager.getApplicableAccessControlPolicies() returns an empty iterator. In this case the getAccessControlPolicies returns the current policies. Also upgraded dependency to Jackrabbit API to 1.6
new a9b8cd7 Update notice files.
new 1ef6653 [maven-release-plugin] prepare release org.apache.sling.jcr.jackrabbit.accessmanager-2.0.4
new 7a8f5c3 [maven-release-plugin] prepare for next development iteration
new baa13c6 SLING-1212 - upgrading to Jackrabbit 2. Also includes re-revert of SLING-1363 and implementation of SLING-1330. Thanks to Felix for getting this started.
new 4a18344 SLING-997 ModifyAceServlet replaces rather than merges privileges
new 60e312a SLING-997 handle merges involving aggregate privileges properly
new 533a4ba SLING-1411 Add replaceAccessControlEntry method to AccessControlUtil Thanks to Ray Davis for the contribution.
new b866e1d SLING-1411 Clarify how to un-set a privilege and fix the sample ACE edit script from the launchpad.content bundle
new d1328f5 SLING-1090 fixed return value of PrivilegesInfo.canDelete(..) for children of the root node + added some unit tests
new d59aaea Removed the 'authorizable' related privilege helpers since they don't work after the upgrade to JR2. To check the authorizable privileges use the 'AuthorizablePrivilegesInfo' service from the jackrabbit.usermanager bundle.
new 1bc3e51 SLING-1457 SLING-1458 - enable support for specifying the position of an ACE (within the ACL) when it is added/updated
new 9cf61d2 SLING-1517 - fixing Maven 3 warnings and switching to released version of animal sniffer
new f66de82 Use released parent pom.
new eee036b SLING-1528 Fixed, reverting to original format, and fixing the reverting the integration tests (keeping the additional integration tests to cover this area)
new 786e49d Clean up code
new d4ac26b SLING-1612 - adding Effective ACL servlet
new 51205d6 SLING-1677 Let AccessManager POST servlets return JSON
new d4f3eec SLING-1698 - setting explicit export version
new 1810e04 updating to released jcr bundles
new 9038481 tabs -> spaces
new 2c7e61a SLING-1805 Fix registration property
new ae5853c updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
new 8868e8f using released version of servlet modules
new 2c72380 updating pom files pre-release
new b67cc19 [maven-release-plugin] prepare release org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
new 4281394 [maven-scm] copy for tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
The 55 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 22/24:
updating pom files pre-release
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 2c723800fff8a35dbe54ebd51a46c129d17553e7
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Nov 3 17:30:30 2010 +0000
updating pom files pre-release
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@1030554 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 43f1f8f..ba5abb6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>10-SNAPSHOT</version>
+ <version>9</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
@@ -65,8 +65,8 @@
org.apache.sling.servlets.post;inline="org/apache/sling/servlets/post/impl/helper/JSONResponse*"
</Embed-Dependency>
<Export-Package>
- org.apache.sling.jcr.jackrabbit.accessmanager;version=2.0.6,
- org.apache.sling.jcr.jackrabbit.accessmanager.post;version=2.0.6
+ org.apache.sling.jcr.jackrabbit.accessmanager;version=2.1.0,
+ org.apache.sling.jcr.jackrabbit.accessmanager.post;version=2.1.0
</Export-Package>
<Sling-Initial-Content />
<Sling-Nodetypes />
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 01/24:
[maven-release-plugin] prepare for next development iteration
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 7a8f5c3bcf9cff8c8631d135758453907e20644e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sat Feb 13 20:13:34 2010 +0000
[maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@909889 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index b9d3bf7..2be7888 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
<artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId>
<packaging>bundle</packaging>
- <version>2.0.4</version>
+ <version>2.0.5-SNAPSHOT</version>
<name>Apache Sling Jackrabbit JSR-283 Access Control Manager Support</name>
<description>
Provides SlingPostOperations for the Jackrabbit JSR-283 Access Control Manager.
@@ -37,13 +37,13 @@
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.0.4
+ scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.0.4
+ scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
</developerConnection>
<url>
- http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.0.4
+ http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-accessmanager
</url>
</scm>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 24/24:
[maven-scm] copy for tag
org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 428139408750aa4822cfc9064709ea3579b10807
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Nov 3 17:52:48 2010 +0000
[maven-scm] copy for tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0@1030568 13f79535-47bb-0310-9956-ffa450edef68
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 20/24:
updating all modules to parent 10-SNAPSHOT in anticipation of emma
additions to parent
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit ae5853cc52b3b0b0639d91fa67746a119e06290e
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Oct 13 20:54:21 2010 +0000
updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@1022288 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index c102ea0..c8cb905 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>9</version>
+ <version>10-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 13/24: Clean
up code
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 786e49d0ce6bb8da87039275b3cf3972ac3222ea
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jul 15 07:30:42 2010 +0000
Clean up code
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@964331 13f79535-47bb-0310-9956-ffa450edef68
---
.../jcr/jackrabbit/accessmanager/post/GetAclServlet.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 7808b6c..1ff9a70 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -43,7 +43,6 @@ import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceNotFoundException;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.jcr.base.util.AccessControlUtil;
import org.slf4j.Logger;
@@ -137,13 +136,13 @@ public class GetAclServlet extends SlingAllMethodsServlet {
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
-
+
try {
Session session = request.getResourceResolver().adaptTo(Session.class);
if (session == null) {
throw new RepositoryException("JCR Session not found");
}
-
+
String resourcePath = null;
Resource resource = request.getResource();
if (resource == null) {
@@ -192,7 +191,7 @@ public class GetAclServlet extends SlingAllMethodsServlet {
}
}
}
-
+
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
@@ -210,7 +209,7 @@ public class GetAclServlet extends SlingAllMethodsServlet {
if (grantedSet != null) {
aceObject.put("granted", grantedSet);
}
-
+
Set<String> deniedSet = (Set<String>) value.get("denied");
if (deniedSet != null) {
aceObject.put("denied", deniedSet);
@@ -247,5 +246,5 @@ public class GetAclServlet extends SlingAllMethodsServlet {
}
return new AccessControlEntry[0];
}
-
+
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 09/24:
SLING-1457 SLING-1458 - enable support for specifying the position of an
ACE (within the ACL) when it is added/updated
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 1bc3e51efb4e838fabaa5a1d46529a0871ad2c98
Author: Eric Norman <en...@apache.org>
AuthorDate: Thu Mar 25 18:34:30 2010 +0000
SLING-1457 SLING-1458 - enable support for specifying the position of an ACE (within the ACL) when it is added/updated
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@927532 13f79535-47bb-0310-9956-ffa450edef68
---
.../jackrabbit/accessmanager/post/GetAclServlet.java | 17 +++++++++++------
.../jackrabbit/accessmanager/post/ModifyAceServlet.java | 5 ++++-
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 76e6360..4eca3a0 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -18,8 +18,10 @@ package org.apache.sling.jcr.jackrabbit.accessmanager.post;
import java.io.IOException;
import java.security.Principal;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -41,6 +43,7 @@ import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceNotFoundException;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.jcr.base.util.AccessControlUtil;
import org.slf4j.Logger;
@@ -191,13 +194,15 @@ public class GetAclServlet extends SlingAllMethodsServlet {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
- JSONObject jsonObj = new JSONObject();
+ List<JSONObject> aclList = new ArrayList<JSONObject>();
Set<Entry<String, Map<String, Set<String>>>> entrySet = aclMap.entrySet();
for (Entry<String, Map<String, Set<String>>> entry : entrySet) {
String principalName = entry.getKey();
Map<String, Set<String>> value = entry.getValue();
-
- JSONObject aceObject = new JSONObject();
+
+ JSONObject aceObject = new JSONObject();
+ aceObject.put("principal", principalName);
+
Set<String> grantedSet = value.get("granted");
if (grantedSet != null) {
aceObject.put("granted", grantedSet);
@@ -208,12 +213,12 @@ public class GetAclServlet extends SlingAllMethodsServlet {
aceObject.put("denied", deniedSet);
}
- jsonObj.put(principalName, aceObject);
+ aclList.add(aceObject);
}
-
+ JSONArray jsonAclArray = new JSONArray(aclList);
// do the dump
- jsonObj.write(response.getWriter());
+ jsonAclArray.write(response.getWriter());
} catch (AccessDeniedException ade) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (ResourceNotFoundException rnfe) {
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index 73718e6..f259e96 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -140,12 +140,15 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
}
}
+ String order = request.getParameter("order");
+
// Make the actual changes.
try {
AccessControlUtil.replaceAccessControlEntry(session, resourcePath, principal,
grantedPrivilegeNames.toArray(new String[grantedPrivilegeNames.size()]),
deniedPrivilegeNames.toArray(new String[deniedPrivilegeNames.size()]),
- removedPrivilegeNames.toArray(new String[removedPrivilegeNames.size()]));
+ removedPrivilegeNames.toArray(new String[removedPrivilegeNames.size()]),
+ order);
if (session.hasPendingChanges()) {
session.save();
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 04/24:
SLING-997 handle merges involving aggregate privileges properly
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 60e312a1ba897610b8ed68ef66344a58685094f2
Author: Eric Norman <en...@apache.org>
AuthorDate: Wed Feb 24 04:44:43 2010 +0000
SLING-997 handle merges involving aggregate privileges properly
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@915670 13f79535-47bb-0310-9956-ffa450edef68
---
.../accessmanager/post/ModifyAceServlet.java | 363 +++++++++++++++------
1 file changed, 256 insertions(+), 107 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index ac3577a..432387e 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -100,7 +100,6 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
/* (non-Javadoc)
* @see org.apache.sling.jackrabbit.accessmanager.post.AbstractAccessPostServlet#handleOperation(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
*/
- @SuppressWarnings("unchecked")
@Override
protected void handleOperation(SlingHttpServletRequest request,
HtmlResponse htmlResponse, List<Modification> changes)
@@ -133,12 +132,70 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
}
}
+ try {
+ AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
- List<String> grantedPrivilegeNames = new ArrayList<String>();
- List<String> deniedPrivilegeNames = new ArrayList<String>();
- //SLING-997: keep track of the privilege names that were posted, so the others can be preserved
- Set<String> postedPrivilegeNames = new HashSet<String>();
- Enumeration parameterNames = request.getParameterNames();
+ //SLING-997: keep track of the privilege names that were posted, so the others can be preserved
+ PrivilegesState privilegesInfo = new PrivilegesState(log.isDebugEnabled());
+
+ //calculate which privileges were POSTed.
+ collectPostedPrivilegeNames(request,
+ accessControlManager,
+ privilegesInfo);
+
+ //find the existing ACL
+ AccessControlList updatedAcl = getAccessControlList(accessControlManager, resourcePath, true);
+
+ //keep track of the existing ACEs for the target principal
+ List<AccessControlEntry> oldAces = processExistingAccessControlEntries(resourcePath,
+ authorizable,
+ accessControlManager,
+ updatedAcl,
+ privilegesInfo);
+
+ //remove the old ACEs. Re-created below.
+ if (!oldAces.isEmpty()) {
+ for (AccessControlEntry ace : oldAces) {
+ updatedAcl.removeAccessControlEntry(ace);
+ }
+ }
+
+ //re-aggregate the granted/denied privileges into the best matched aggregate privilege
+ reaggregatePrivileges(resourcePath,
+ accessControlManager,
+ privilegesInfo);
+
+ //add fresh ACEs with the granted privileges
+ buildFreshAccessControlEntries(authorizable,
+ accessControlManager,
+ updatedAcl,
+ privilegesInfo);
+
+ //store the updated ACL
+ accessControlManager.setPolicy(resourcePath, updatedAcl);
+ if (session.hasPendingChanges()) {
+ session.save();
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Updated ACE for principalId {0} for resource {1) from {2} to {3}", new Object [] {
+ authorizable.getID(), resourcePath, privilegesInfo.oldPrivileges.toString(), privilegesInfo.newPrivileges.toString()
+ });
+ }
+ } catch (RepositoryException re) {
+ throw new RepositoryException("Failed to create ace.", re);
+ }
+ }
+
+
+ /**
+ * Collect the privileges to assign from the http request.
+ */
+ private void collectPostedPrivilegeNames(SlingHttpServletRequest request,
+ AccessControlManager accessControlManager,
+ PrivilegesState privilegesInfo) throws RepositoryException {
+
+ Enumeration<?> parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
Object nextElement = parameterNames.nextElement();
if (nextElement instanceof String) {
@@ -146,144 +203,236 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
if (paramName.startsWith("privilege@")) {
String privilegeName = paramName.substring(10);
//keep track of which privileges should be changed
- postedPrivilegeNames.add(privilegeName);
+ privilegesInfo.postedPrivilegeNames.add(privilegeName);
String parameterValue = request.getParameter(paramName);
if (parameterValue != null && parameterValue.length() > 0) {
if ("granted".equals(parameterValue)) {
- grantedPrivilegeNames.add(privilegeName);
+ Privilege privilege = accessControlManager.privilegeFromName(privilegeName);
+ if (privilege.isAggregate()) {
+ Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
+ for (Privilege privilege2 : aggregatePrivileges) {
+ privilegesInfo.grantedPrivilegeNames.add(privilege2.getName());
+ }
+ } else {
+ privilegesInfo.grantedPrivilegeNames.add(privilegeName);
+ }
} else if ("denied".equals(parameterValue)) {
- deniedPrivilegeNames.add(privilegeName);
+ Privilege privilege = accessControlManager.privilegeFromName(privilegeName);
+ if (privilege.isAggregate()) {
+ Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
+ for (Privilege privilege2 : aggregatePrivileges) {
+ privilegesInfo.deniedPrivilegeNames.add(privilege2.getName());
+ }
+ } else {
+ privilegesInfo.deniedPrivilegeNames.add(privilegeName);
+ }
}
}
}
}
}
+ }
+
+ /**
+ * Process the existing ACL to determine which privileges to preserve.
+ */
+ private List<AccessControlEntry> processExistingAccessControlEntries(
+ String resourcePath,
+ Authorizable authorizable,
+ AccessControlManager accessControlManager,
+ AccessControlList updatedAcl,
+ PrivilegesState privilegesInfo) throws RepositoryException {
+
+ String principalId = authorizable.getPrincipal().getName();
+ AccessControlEntry[] accessControlEntries = updatedAcl.getAccessControlEntries();
+ List<AccessControlEntry> oldAces = new ArrayList<AccessControlEntry>();
+ for (AccessControlEntry ace : accessControlEntries) {
+ if (principalId.equals(ace.getPrincipal().getName())) {
+ if (log.isDebugEnabled()) {
+ log.debug("Found Existing ACE for principal {0} on resource: ", new Object[] {principalId, resourcePath});
+ }
+ oldAces.add(ace);
- try {
- AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
- AccessControlList updatedAcl = getAccessControlList(accessControlManager, resourcePath, true);
-
- StringBuilder oldPrivileges = null;
- StringBuilder newPrivileges = null;
- if (log.isDebugEnabled()) {
- oldPrivileges = new StringBuilder();
- newPrivileges = new StringBuilder();
- }
+ boolean isAllow = AccessControlUtil.isAllow(ace);
+ Privilege[] privileges = ace.getPrivileges();
- List<Privilege> preserveGrantedPrivileges = new ArrayList<Privilege>();
- List<Privilege> preserveDeniedPrivileges = new ArrayList<Privilege>();
-
- //keep track of the existing Aces for the target principal
- AccessControlEntry[] accessControlEntries = updatedAcl.getAccessControlEntries();
- List<AccessControlEntry> oldAces = new ArrayList<AccessControlEntry>();
- for (AccessControlEntry ace : accessControlEntries) {
- if (principalId.equals(ace.getPrincipal().getName())) {
- if (log.isDebugEnabled()) {
- log.debug("Found Existing ACE for principal {0} on resource: ", new Object[] {principalId, resourcePath});
+ //build a list of (merged and expanded) privileges
+ Set<Privilege> mergedExistingPrivileges = new HashSet<Privilege>();
+ for (Privilege privilege : privileges) {
+ if (privilege.isAggregate()) {
+ Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
+ for (Privilege privilege2 : aggregatePrivileges) {
+ mergedExistingPrivileges.add(privilege2);
+ }
+ } else {
+ mergedExistingPrivileges.add(privilege);
}
- oldAces.add(ace);
-
- boolean isAllow = AccessControlUtil.isAllow(ace);
- Privilege[] privileges = ace.getPrivileges();
- for (Privilege privilege : privileges) {
- String privilegeName = privilege.getName();
- if (!postedPrivilegeNames.contains(privilegeName)) {
- //this privilege was not posted, so record the existing state to be
- // preserved when the ACE is re-created below
- if (isAllow) {
- preserveGrantedPrivileges.add(privilege);
- } else {
- preserveDeniedPrivileges.add(privilege);
- }
+ }
+
+ //now process the merged privileges set
+ for (Privilege privilege : mergedExistingPrivileges) {
+ String privilegeName = privilege.getName();
+ if (!privilegesInfo.postedPrivilegeNames.contains(privilegeName)) {
+ //this privilege was not posted, so record the existing state to be
+ // preserved when the ACE is re-created below
+ if (isAllow) {
+ privilegesInfo.grantedPrivilegeNames.add(privilegeName);
+ } else {
+ privilegesInfo.deniedPrivilegeNames.add(privilegeName);
}
+ }
- if (log.isDebugEnabled()) {
- //collect the information for debug logging
- if (oldPrivileges.length() > 0) {
- oldPrivileges.append(", "); //separate entries by commas
- }
+ if (log.isDebugEnabled()) {
+ //collect the information for debug logging
+ if (privilegesInfo.oldPrivileges.length() > 0) {
+ privilegesInfo.oldPrivileges.append(", "); //separate entries by commas
}
+ if (isAllow) {
+ privilegesInfo.oldPrivileges.append("granted=");
+ } else {
+ privilegesInfo.oldPrivileges.append("denied=");
+ }
+ privilegesInfo.oldPrivileges.append(privilege.getName());
}
}
}
+ }
+
+ return oldAces;
+ }
+
+ /**
+ * Given the set of granted/denied privileges, try to combine them
+ * into the best aggregate Privilege that contains them all.
+ */
+ private void reaggregatePrivileges(
+ String resourcePath,
+ AccessControlManager accessControlManager,
+ PrivilegesState privilegesInfo) throws RepositoryException {
+ Privilege[] supportedPrivileges = accessControlManager.getSupportedPrivileges(resourcePath);
+ for (Privilege privilege : supportedPrivileges) {
+ if (privilege.isAggregate()) {
+ boolean grantedAggregatePrivilege = true;
+ boolean deniedAggregatePrivilege = true;
+ Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
+ for (Privilege privilege2 : aggregatePrivileges) {
+ String name = privilege2.getName();
+ if (!privilegesInfo.grantedPrivilegeNames.contains(name)) {
+ grantedAggregatePrivilege = false;
+ }
+ if (!privilegesInfo.deniedPrivilegeNames.contains(name)) {
+ deniedAggregatePrivilege = false;
+ }
+ }
+
+ if (grantedAggregatePrivilege) {
+ //add the aggregate privilege and remove the containing parts
+ privilegesInfo.grantedPrivilegeNames.add(privilege.getName());
+ for (Privilege privilege2 : aggregatePrivileges) {
+ String name = privilege2.getName();
+ privilegesInfo.grantedPrivilegeNames.remove(name);
+ }
+ }
- //remove the old aces
- if (!oldAces.isEmpty()) {
- for (AccessControlEntry ace : oldAces) {
- updatedAcl.removeAccessControlEntry(ace);
+ if (deniedAggregatePrivilege) {
+ //add the aggregate privilege and remove the containing parts
+ privilegesInfo.deniedPrivilegeNames.add(privilege.getName());
+ for (Privilege privilege2 : aggregatePrivileges) {
+ String name = privilege2.getName();
+ privilegesInfo.deniedPrivilegeNames.remove(name);
+ }
}
}
+ }
+ }
+
+ /**
+ * Create new ACE for the granted and denied privileges.
+ */
+ private void buildFreshAccessControlEntries(
+ Authorizable authorizable,
+ AccessControlManager accessControlManager,
+ AccessControlList updatedAcl,
+ PrivilegesState privilegesInfo) throws RepositoryException {
+ List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
+ for (String name : privilegesInfo.grantedPrivilegeNames) {
+ if (name.length() == 0) {
+ continue; //empty, skip it.
+ }
+ Privilege privilege = accessControlManager.privilegeFromName(name);
+ grantedPrivilegeList.add(privilege);
+ }
+
+ if (log.isDebugEnabled()) {
+ for (Privilege privilege : grantedPrivilegeList) {
+ if (privilegesInfo.newPrivileges.length() > 0) {
+ privilegesInfo.newPrivileges.append(", "); //separate entries by commas
+ }
+ privilegesInfo.newPrivileges.append("granted=");
+ privilegesInfo.newPrivileges.append(privilege.getName());
+ }
+ }
- //add a fresh ACE with the granted privileges
- List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
- for (String name : grantedPrivilegeNames) {
+ if (grantedPrivilegeList.size() > 0) {
+ Principal principal = authorizable.getPrincipal();
+ updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
+ }
+
+ //if the authorizable is a user (not a group) process any denied privileges
+ if (!authorizable.isGroup()) {
+ //add a fresh ACE with the denied privileges
+ List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
+ for (String name : privilegesInfo.deniedPrivilegeNames) {
if (name.length() == 0) {
continue; //empty, skip it.
}
Privilege privilege = accessControlManager.privilegeFromName(name);
- grantedPrivilegeList.add(privilege);
+ deniedPrivilegeList.add(privilege);
}
- //add the privileges that should be preserved
- grantedPrivilegeList.addAll(preserveGrantedPrivileges);
-
+
if (log.isDebugEnabled()) {
- for (Privilege privilege : grantedPrivilegeList) {
- if (newPrivileges.length() > 0) {
- newPrivileges.append(", "); //separate entries by commas
+ for (Privilege privilege : deniedPrivilegeList) {
+ if (privilegesInfo.newPrivileges.length() > 0) {
+ privilegesInfo.newPrivileges.append(", "); //separate entries by commas
}
- newPrivileges.append("granted=");
- newPrivileges.append(privilege.getName());
- }
+ privilegesInfo.newPrivileges.append("denied=");
+ privilegesInfo.newPrivileges.append(privilege.getName());
+ }
}
-
- if (grantedPrivilegeList.size() > 0) {
+
+ if (deniedPrivilegeList.size() > 0) {
Principal principal = authorizable.getPrincipal();
- updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
+ AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);
}
+ }
+ }
+
+ /**
+ * Contains the information about the privilege state as it
+ * progresses through the update process.
+ */
+ private static class PrivilegesState {
+ //stores the names of the privileges that were POSTed
+ Set<String> postedPrivilegeNames = new HashSet<String>();
+
+ //stores the names of the privileges to be granted
+ Set<String> grantedPrivilegeNames = new HashSet<String>();
- //if the authorizable is a user (not a group) process any denied privileges
- if (!authorizable.isGroup()) {
- //add a fresh ACE with the denied privileges
- List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
- for (String name : deniedPrivilegeNames) {
- if (name.length() == 0) {
- continue; //empty, skip it.
- }
- Privilege privilege = accessControlManager.privilegeFromName(name);
- deniedPrivilegeList.add(privilege);
- }
- //add the privileges that should be preserved
- deniedPrivilegeList.addAll(preserveDeniedPrivileges);
-
- if (log.isDebugEnabled()) {
- for (Privilege privilege : deniedPrivilegeList) {
- if (newPrivileges.length() > 0) {
- newPrivileges.append(", "); //separate entries by commas
- }
- newPrivileges.append("denied=");
- newPrivileges.append(privilege.getName());
- }
- }
-
- if (deniedPrivilegeList.size() > 0) {
- Principal principal = authorizable.getPrincipal();
- AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);
- }
- }
+ //stores the names of the privileges to be denied
+ Set<String> deniedPrivilegeNames = new HashSet<String>();
- accessControlManager.setPolicy(resourcePath, updatedAcl);
- if (session.hasPendingChanges()) {
- session.save();
- }
+ //collects debug information about the previous privileges
+ StringBuilder oldPrivileges = null;
+
+ //collects debug information about the new privileges
+ StringBuilder newPrivileges = null;
- if (log.isDebugEnabled()) {
- log.debug("Updated ACE for principalId {0} for resource {1) from {2} to {3}", new Object [] {
- authorizable.getID(), resourcePath, oldPrivileges.toString(), newPrivileges.toString()
- });
+ public PrivilegesState(boolean isDebugEnabled) {
+ if (isDebugEnabled) {
+ oldPrivileges = new StringBuilder();
+ newPrivileges = new StringBuilder();
}
- } catch (RepositoryException re) {
- throw new RepositoryException("Failed to create ace.", re);
}
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 14/24:
SLING-1612 - adding Effective ACL servlet
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit d4ac26b8252bc6f6520f1ffbd0f9f4854619eb04
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Mon Jul 26 14:34:35 2010 +0000
SLING-1612 - adding Effective ACL servlet
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@979311 13f79535-47bb-0310-9956-ffa450edef68
---
.../accessmanager/post/AbstractGetAclServlet.java | 165 +++++++++++++++++++++
.../accessmanager/post/GetAclServlet.java | 142 +-----------------
.../accessmanager/post/GetEffectiveAclServlet.java | 116 +++++++++++++++
3 files changed, 285 insertions(+), 138 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractGetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractGetAclServlet.java
new file mode 100644
index 0000000..27986c9
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractGetAclServlet.java
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.jcr.jackrabbit.accessmanager.post;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Item;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.Privilege;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceNotFoundException;
+import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.jcr.base.util.AccessControlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("serial")
+public abstract class AbstractGetAclServlet extends SlingAllMethodsServlet {
+
+ /**
+ * default log
+ */
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.api.servlets.SlingSafeMethodsServlet#doGet(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.SlingHttpServletResponse)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void doGet(SlingHttpServletRequest request,
+ SlingHttpServletResponse response) throws ServletException,
+ IOException {
+
+ try {
+ Session session = request.getResourceResolver().adaptTo(Session.class);
+ if (session == null) {
+ throw new RepositoryException("JCR Session not found");
+ }
+
+ String resourcePath = null;
+ Resource resource = request.getResource();
+ if (resource == null) {
+ throw new ResourceNotFoundException("Resource not found.");
+ } else {
+ Item item = resource.adaptTo(Item.class);
+ if (item != null) {
+ resourcePath = item.getPath();
+ } else {
+ throw new ResourceNotFoundException("Resource is not a JCR Node");
+ }
+ }
+
+ AccessControlEntry[] declaredAccessControlEntries = getAccessControlEntries(session, resourcePath);
+ Map<String, Map<String, Object>> aclMap = new LinkedHashMap<String, Map<String,Object>>();
+ int sequence = 0;
+ for (AccessControlEntry ace : declaredAccessControlEntries) {
+ Principal principal = ace.getPrincipal();
+ Map<String, Object> map = aclMap.get(principal.getName());
+ if (map == null) {
+ map = new LinkedHashMap<String, Object>();
+ aclMap.put(principal.getName(), map);
+ map.put("order", sequence++);
+ }
+
+ boolean allow = AccessControlUtil.isAllow(ace);
+ if (allow) {
+ Set<String> grantedSet = (Set<String>) map.get("granted");
+ if (grantedSet == null) {
+ grantedSet = new LinkedHashSet<String>();
+ map.put("granted", grantedSet);
+ }
+ Privilege[] privileges = ace.getPrivileges();
+ for (Privilege privilege : privileges) {
+ grantedSet.add(privilege.getName());
+ }
+ } else {
+ Set<String> deniedSet = (Set<String>) map.get("denied");
+ if (deniedSet == null) {
+ deniedSet = new LinkedHashSet<String>();
+ map.put("denied", deniedSet);
+ }
+ Privilege[] privileges = ace.getPrivileges();
+ for (Privilege privilege : privileges) {
+ deniedSet.add(privilege.getName());
+ }
+ }
+ }
+
+
+ response.setContentType("application/json");
+ response.setCharacterEncoding("UTF-8");
+
+ List<JSONObject> aclList = new ArrayList<JSONObject>();
+ Set<Entry<String, Map<String, Object>>> entrySet = aclMap.entrySet();
+ for (Entry<String, Map<String, Object>> entry : entrySet) {
+ String principalName = entry.getKey();
+ Map<String, Object> value = entry.getValue();
+
+ JSONObject aceObject = new JSONObject();
+ aceObject.put("principal", principalName);
+
+ Set<String> grantedSet = (Set<String>) value.get("granted");
+ if (grantedSet != null) {
+ aceObject.put("granted", grantedSet);
+ }
+
+ Set<String> deniedSet = (Set<String>) value.get("denied");
+ if (deniedSet != null) {
+ aceObject.put("denied", deniedSet);
+ }
+ aceObject.put("order", value.get("order"));
+ aclList.add(aceObject);
+ }
+ JSONObject jsonAclMap = new JSONObject(aclMap);
+ for ( JSONObject jsonObj : aclList) {
+ jsonAclMap.put(jsonObj.getString("principal"), jsonObj);
+ }
+ jsonAclMap.write(response.getWriter());
+ // do the dump
+ } catch (AccessDeniedException ade) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (ResourceNotFoundException rnfe) {
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, rnfe.getMessage());
+ } catch (Throwable throwable) {
+ log.debug("Exception while handling GET "
+ + request.getResource().getPath() + " with "
+ + getClass().getName(), throwable);
+ throw new ServletException(throwable);
+ }
+ }
+
+ protected abstract AccessControlEntry[] getAccessControlEntries(Session session, String absPath) throws RepositoryException;
+
+}
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 1ff9a70..7fadfa5 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -16,37 +16,14 @@
*/
package org.apache.sling.jcr.jackrabbit.accessmanager.post;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.jcr.AccessDeniedException;
-import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.security.AccessControlEntry;
import javax.jcr.security.AccessControlList;
import javax.jcr.security.AccessControlManager;
import javax.jcr.security.AccessControlPolicy;
-import javax.jcr.security.Privilege;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.SlingHttpServletResponse;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceNotFoundException;
-import org.apache.sling.api.servlets.SlingAllMethodsServlet;
-import org.apache.sling.commons.json.JSONObject;
import org.apache.sling.jcr.base.util.AccessControlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* <p>
@@ -120,122 +97,11 @@ import org.slf4j.LoggerFactory;
* @scr.property name="sling.servlet.selectors" value="acl"
* @scr.property name="sling.servlet.extensions " value="json"
*/
-public class GetAclServlet extends SlingAllMethodsServlet {
- private static final long serialVersionUID = 3391376559396223184L;
-
- /**
- * default log
- */
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /* (non-Javadoc)
- * @see org.apache.sling.api.servlets.SlingSafeMethodsServlet#doGet(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.SlingHttpServletResponse)
- */
- @SuppressWarnings("unchecked")
- @Override
- protected void doGet(SlingHttpServletRequest request,
- SlingHttpServletResponse response) throws ServletException,
- IOException {
-
- try {
- Session session = request.getResourceResolver().adaptTo(Session.class);
- if (session == null) {
- throw new RepositoryException("JCR Session not found");
- }
-
- String resourcePath = null;
- Resource resource = request.getResource();
- if (resource == null) {
- throw new ResourceNotFoundException("Resource not found.");
- } else {
- Item item = resource.adaptTo(Item.class);
- if (item != null) {
- resourcePath = item.getPath();
- } else {
- throw new ResourceNotFoundException("Resource is not a JCR Node");
- }
- }
-
- AccessControlEntry[] declaredAccessControlEntries = getDeclaredAccessControlEntries(session, resourcePath);
- Map<String, Map<String, Object>> aclMap = new LinkedHashMap<String, Map<String,Object>>();
- int sequence = 0;
- for (AccessControlEntry ace : declaredAccessControlEntries) {
- Principal principal = ace.getPrincipal();
- Map<String, Object> map = aclMap.get(principal.getName());
- if (map == null) {
- map = new LinkedHashMap<String, Object>();
- aclMap.put(principal.getName(), map);
- map.put("order", sequence++);
- }
-
- boolean allow = AccessControlUtil.isAllow(ace);
- if (allow) {
- Set<String> grantedSet = (Set<String>) map.get("granted");
- if (grantedSet == null) {
- grantedSet = new LinkedHashSet<String>();
- map.put("granted", grantedSet);
- }
- Privilege[] privileges = ace.getPrivileges();
- for (Privilege privilege : privileges) {
- grantedSet.add(privilege.getName());
- }
- } else {
- Set<String> deniedSet = (Set<String>) map.get("denied");
- if (deniedSet == null) {
- deniedSet = new LinkedHashSet<String>();
- map.put("denied", deniedSet);
- }
- Privilege[] privileges = ace.getPrivileges();
- for (Privilege privilege : privileges) {
- deniedSet.add(privilege.getName());
- }
- }
- }
-
-
- response.setContentType("application/json");
- response.setCharacterEncoding("UTF-8");
-
- List<JSONObject> aclList = new ArrayList<JSONObject>();
- Set<Entry<String, Map<String, Object>>> entrySet = aclMap.entrySet();
- for (Entry<String, Map<String, Object>> entry : entrySet) {
- String principalName = entry.getKey();
- Map<String, Object> value = entry.getValue();
-
- JSONObject aceObject = new JSONObject();
- aceObject.put("principal", principalName);
-
- Set<String> grantedSet = (Set<String>) value.get("granted");
- if (grantedSet != null) {
- aceObject.put("granted", grantedSet);
- }
-
- Set<String> deniedSet = (Set<String>) value.get("denied");
- if (deniedSet != null) {
- aceObject.put("denied", deniedSet);
- }
- aceObject.put("order", value.get("order"));
- aclList.add(aceObject);
- }
- JSONObject jsonAclMap = new JSONObject(aclMap);
- for ( JSONObject jsonObj : aclList) {
- jsonAclMap.put(jsonObj.getString("principal"), jsonObj);
- }
- jsonAclMap.write(response.getWriter());
- // do the dump
- } catch (AccessDeniedException ade) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND);
- } catch (ResourceNotFoundException rnfe) {
- response.sendError(HttpServletResponse.SC_NOT_FOUND, rnfe.getMessage());
- } catch (Throwable throwable) {
- log.debug("Exception while handling GET "
- + request.getResource().getPath() + " with "
- + getClass().getName(), throwable);
- throw new ServletException(throwable);
- }
- }
+public class GetAclServlet extends AbstractGetAclServlet {
+ private static final long serialVersionUID = 3391376559396223185L;
- private AccessControlEntry[] getDeclaredAccessControlEntries(Session session, String absPath) throws RepositoryException {
+ @Override
+ protected AccessControlEntry[] getAccessControlEntries(Session session, String absPath) throws RepositoryException {
AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
AccessControlPolicy[] policies = accessControlManager.getPolicies(absPath);
for (AccessControlPolicy accessControlPolicy : policies) {
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java
new file mode 100644
index 0000000..7b7d923
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.jcr.jackrabbit.accessmanager.post;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+
+import org.apache.sling.jcr.base.util.AccessControlUtil;
+
+/**
+ * <p>
+ * Sling GET servlet implementation for dumping the declared ACL of a resource to JSON.
+ * </p>
+ * <h2>Rest Service Description</h2>
+ * <p>
+ * Mapped to the default resourceType. Gets and Acl for a resource. Get of the form
+ * >resource<.acl.json Provided the user has access to the ACL, they get a chunk of
+ * JSON of the form.
+ * </p>
+ * <h4>Methods</h4>
+ * <ul>
+ * <li>GET</li>
+ * </ul>
+ * <h4>Response</h4>
+ * <dl>
+ * <dt>200</dt>
+ * <dd>Success.</dd>
+ * <dt>404</dt>
+ * <dd>The resource was not found.</dd>
+ * <dt>500</dt>
+ * <dd>Failure. HTML explains the failure.</dd>
+ * </dl>
+ * <h4>Example Response</h4>
+ * <code>
+ * <pre>
+ * {
+ * "principalNameA":
+ * { "granted" : [
+ * "permission1",
+ * "permission2",
+ * "permission3",
+ * "permission4" ],
+ * "denied" : [
+ * "permission5",
+ * "permission6",
+ * "permission7",
+ * "permission8"]
+ * },
+ * "principalNameB":
+ * { "granted" : [
+ * "permission1",
+ * "permission2",
+ * "permission3",
+ * "permission4" ],
+ * "denied" : [
+ * "permission5",
+ * "permission6",
+ * "permission7",
+ * "permission8"] },
+ * "principalNameC":
+ * { "granted" : [
+ * "permission1",
+ * "permission2",
+ * "permission3",
+ * "permission4" ],
+ * "denied" : [
+ * "permission5",
+ * "permission6",
+ * "permission7",
+ * "permission8"] }
+ * }
+ * </pre>
+ * </code>
+ *
+ * @scr.component immediate="true"
+ * @scr.service interface="javax.servlet.Servlet"
+ * @scr.property name="sling.servlet.resourceTypes" value="sling/servlet/default"
+ * @scr.property name="sling.servlet.methods" value="GET"
+ * @scr.property name="sling.servlet.selectors" value="eacl"
+ * @scr.property name="sling.servlet.extensions " value="json"
+ */
+@SuppressWarnings("serial")
+public class GetEffectiveAclServlet extends AbstractGetAclServlet {
+
+ @Override
+ protected AccessControlEntry[] getAccessControlEntries(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];
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 07/24:
SLING-1090 fixed return value of PrivilegesInfo.canDelete(..) for children
of the root node + added some unit tests
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit d1328f5cb05a27bf56bf4d7aeffca23e016d94c7
Author: Eric Norman <en...@apache.org>
AuthorDate: Fri Mar 5 23:21:58 2010 +0000
SLING-1090 fixed return value of PrivilegesInfo.canDelete(..) for children of the root node + added some unit tests
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@919665 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
index 18da9b2..a895130 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
@@ -444,7 +444,15 @@ public class PrivilegesInfo {
try {
AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
- String parentPath = absPath.substring(0, absPath.lastIndexOf('/'));
+ String parentPath;
+ int lastSlash = absPath.lastIndexOf('/');
+ if (lastSlash == 0) {
+ //the parent is the root folder.
+ parentPath = "/";
+ } else {
+ //strip the last segment
+ parentPath = absPath.substring(0, lastSlash);
+ }
boolean canDelete = accessControlManager.hasPrivileges(absPath, new Privilege[] {
accessControlManager.privilegeFromName(Privilege.JCR_REMOVE_NODE)
}) && canDeleteChildren(session, parentPath);
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 10/24:
SLING-1517 - fixing Maven 3 warnings and switching to released version of
animal sniffer
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 9cf61d2e77d3cff72c7549e5138343e533a7714d
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue May 4 21:17:40 2010 +0000
SLING-1517 - fixing Maven 3 warnings and switching to released version of animal sniffer
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@941046 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index be6a25a..d0694c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,8 +62,8 @@
<Private-Package>
</Private-Package>
<Export-Package>
- org.apache.sling.jcr.jackrabbit.accessmanager;version=${pom.version},
- org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${pom.version}
+ org.apache.sling.jcr.jackrabbit.accessmanager;version=${project.version},
+ org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${project.version}
</Export-Package>
<Sling-Initial-Content />
<Sling-Nodetypes />
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 21/24: using
released version of servlet modules
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 8868e8fad9f185e961367b12062c4df7f9ee88ca
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Oct 15 00:18:13 2010 +0000
using released version of servlet modules
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@1022781 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index c8cb905..43f1f8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -117,7 +117,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.post</artifactId>
- <version>2.0.5-SNAPSHOT</version>
+ <version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 02/24:
SLING-1212 - upgrading to Jackrabbit 2. Also includes re-revert of
SLING-1363 and implementation of SLING-1330. Thanks to Felix for getting
this started.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit baa13c611fa3f1ddd3ca42e1cc644e5ec1138543
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Thu Feb 18 15:08:43 2010 +0000
SLING-1212 - upgrading to Jackrabbit 2. Also includes re-revert of SLING-1363 and implementation of SLING-1330. Thanks to Felix for getting this started.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@911430 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 34 ++++++++++++++--------
.../jackrabbit/accessmanager/PrivilegesInfo.java | 10 +++----
.../post/AbstractAccessPostServlet.java | 8 ++---
.../accessmanager/post/DeleteAcesServlet.java | 6 ++--
.../accessmanager/post/GetAclServlet.java | 10 +++----
.../accessmanager/post/ModifyAceServlet.java | 8 ++---
6 files changed, 43 insertions(+), 33 deletions(-)
diff --git a/pom.xml b/pom.xml
index 2be7888..be6a25a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,9 +7,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,7 +18,7 @@
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
+
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.sling</groupId>
@@ -63,7 +63,7 @@
</Private-Package>
<Export-Package>
org.apache.sling.jcr.jackrabbit.accessmanager;version=${pom.version},
- org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${pom.version}
+ org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${pom.version}
</Export-Package>
<Sling-Initial-Content />
<Sling-Nodetypes />
@@ -92,32 +92,42 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
-
+
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.json</artifactId>
<version>2.0.4-incubator</version>
</dependency>
-
+
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.api</artifactId>
<version>2.0.8</version>
+ <scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-api</artifactId>
+ <version>2.0.0</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.post</artifactId>
<version>2.0.4-incubator</version>
+ <scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-api</artifactId>
- <version>1.6.0</version>
- </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.base</artifactId>
- <version>2.0.4-incubator</version>
+ <version>2.0.7-SNAPSHOT</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
index 3143650..18da9b2 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
@@ -31,12 +31,12 @@ import java.util.Set;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.Privilege;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlEntry;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlPolicy;
-import org.apache.jackrabbit.api.jsr283.security.Privilege;
import org.apache.jackrabbit.api.security.principal.PrincipalManager;
import org.apache.sling.jcr.base.util.AccessControlUtil;
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
index 45d9b2e..e13b179 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
@@ -22,14 +22,14 @@ import java.util.List;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.AccessControlPolicyIterator;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlPolicy;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlPolicyIterator;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.ResourceNotFoundException;
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/DeleteAcesServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/DeleteAcesServlet.java
index 3d8ea7e..dba545a 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/DeleteAcesServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/DeleteAcesServlet.java
@@ -26,9 +26,9 @@ import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlEntry;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceNotFoundException;
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 855a966..76e6360 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -28,14 +28,14 @@ import javax.jcr.AccessDeniedException;
import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.Privilege;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlEntry;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlPolicy;
-import org.apache.jackrabbit.api.jsr283.security.Privilege;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index 07715f5..b8efad6 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -24,11 +24,11 @@ import java.util.List;
import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.AccessControlList;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.Privilege;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlEntry;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlList;
-import org.apache.jackrabbit.api.jsr283.security.AccessControlManager;
-import org.apache.jackrabbit.api.jsr283.security.Privilege;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
import org.apache.sling.api.SlingHttpServletRequest;
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 19/24:
SLING-1805 Fix registration property
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 2c7e61a4bf0a42d1ac63c07c773aa9e09cacf198
Author: Felix Meschberger <fm...@apache.org>
AuthorDate: Sun Sep 26 10:26:08 2010 +0000
SLING-1805 Fix registration property
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@1001405 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java | 2 +-
.../jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 7fadfa5..399dbb1 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -95,7 +95,7 @@ import org.apache.sling.jcr.base.util.AccessControlUtil;
* @scr.property name="sling.servlet.resourceTypes" value="sling/servlet/default"
* @scr.property name="sling.servlet.methods" value="GET"
* @scr.property name="sling.servlet.selectors" value="acl"
- * @scr.property name="sling.servlet.extensions " value="json"
+ * @scr.property name="sling.servlet.extensions" value="json"
*/
public class GetAclServlet extends AbstractGetAclServlet {
private static final long serialVersionUID = 3391376559396223185L;
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java
index 7b7d923..813d35f 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetEffectiveAclServlet.java
@@ -5,9 +5,9 @@
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -95,7 +95,7 @@ import org.apache.sling.jcr.base.util.AccessControlUtil;
* @scr.property name="sling.servlet.resourceTypes" value="sling/servlet/default"
* @scr.property name="sling.servlet.methods" value="GET"
* @scr.property name="sling.servlet.selectors" value="eacl"
- * @scr.property name="sling.servlet.extensions " value="json"
+ * @scr.property name="sling.servlet.extensions" value="json"
*/
@SuppressWarnings("serial")
public class GetEffectiveAclServlet extends AbstractGetAclServlet {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 08/24:
Removed the 'authorizable' related privilege helpers since they don't work
after the upgrade to JR2. To check the authorizable privileges use the
'AuthorizablePrivilegesInfo' service from the jackrabbit.usermanager
bundle.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit d59aaea2f3a429c7f328da40e0987ace2eae2d5a
Author: Eric Norman <en...@apache.org>
AuthorDate: Fri Mar 19 19:34:24 2010 +0000
Removed the 'authorizable' related privilege helpers since they don't work after the upgrade to JR2. To check the authorizable privileges use the 'AuthorizablePrivilegesInfo' service from the jackrabbit.usermanager bundle.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@925395 13f79535-47bb-0310-9956-ffa450edef68
---
.../jackrabbit/accessmanager/PrivilegesInfo.java | 60 ----------------------
1 file changed, 60 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
index a895130..171c81e 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
@@ -16,8 +16,6 @@
*/
package org.apache.sling.jcr.jackrabbit.accessmanager;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.security.Principal;
import java.util.Arrays;
import java.util.HashSet;
@@ -37,7 +35,6 @@ import javax.jcr.security.AccessControlManager;
import javax.jcr.security.AccessControlPolicy;
import javax.jcr.security.Privilege;
-import org.apache.jackrabbit.api.security.principal.PrincipalManager;
import org.apache.sling.jcr.base.util.AccessControlUtil;
/**
@@ -564,61 +561,4 @@ public class PrivilegesInfo {
}
}
-
- /**
- * Checks whether the current user has been granted privileges
- * to update the properties of the specified principal.
- *
- * @param session the JCR session for the current user
- * @param principalID the id of the principal to check
- * @return true if the current user has the privileges, false otherwise
- */
- public boolean canUpdateAuthorizable(Session session, String principalID) {
- try {
- PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
- Principal principal = principalManager.getPrincipal(principalID);
- if (principal == null) {
- return false;
- }
-
- String path = getAuthorizableItemPath(principal);
- return canModifyProperties(session, path);
- } catch (Exception e) {
- //just eat it.
- return false;
- }
- }
- private String getAuthorizableItemPath(Principal principal)
- throws NoSuchMethodException, IllegalAccessException,
- InvocationTargetException {
- //should check if principal implements ItemBasedPrincipal, but it is not visible here so use reflection instead
- Method method = principal.getClass().getMethod("getPath");
- String path = (String)method.invoke(principal);
- return path;
- }
-
- /**
- * Checks whether the current user has been granted privileges
- * to delete the specified principal.
- *
- * @param session the JCR session for the current user
- * @param principalID the id of the principal to check
- * @return true if the current user has the privileges, false otherwise
- */
- public boolean canDeleteAuthorizable(Session session, String principalID) {
- try {
- PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
- Principal principal = principalManager.getPrincipal(principalID);
- if (principal == null) {
- return false;
- }
-
- //should check if principal implements ItemBasedPrincipal, but it is not visible here so use reflection instead
- String path = getAuthorizableItemPath(principal);
- return canDelete(session, path);
- } catch (Exception e) {
- //just eat it.
- return false;
- }
- }
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 16/24:
SLING-1698 - setting explicit export version
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit d4f3eec70c7316b3b192ddbd8e703b12d4640505
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Sep 1 15:23:53 2010 +0000
SLING-1698 - setting explicit export version
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@991571 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 9ddaffe..6af1d23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,8 +65,8 @@
org.apache.sling.servlets.post;inline="org/apache/sling/servlets/post/impl/helper/JSONResponse*"
</Embed-Dependency>
<Export-Package>
- org.apache.sling.jcr.jackrabbit.accessmanager;version=${project.version},
- org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${project.version}
+ org.apache.sling.jcr.jackrabbit.accessmanager;version=2.0.6,
+ org.apache.sling.jcr.jackrabbit.accessmanager.post;version=2.0.6
</Export-Package>
<Sling-Initial-Content />
<Sling-Nodetypes />
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 12/24:
SLING-1528 Fixed, reverting to original format,
and fixing the reverting the integration tests (keeping the additional
integration tests to cover this area)
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit eee036b12a340c0e819c21f3773e9fc246ba00b1
Author: Ian Boston <ie...@apache.org>
AuthorDate: Mon May 24 11:52:02 2010 +0000
SLING-1528 Fixed, reverting to original format, and fixing the reverting the integration tests (keeping the additional integration tests to cover this area)
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@947613 13f79535-47bb-0310-9956-ffa450edef68
---
.../accessmanager/post/GetAclServlet.java | 35 ++++++++++++----------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
index 4eca3a0..7808b6c 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/GetAclServlet.java
@@ -132,7 +132,8 @@ public class GetAclServlet extends SlingAllMethodsServlet {
/* (non-Javadoc)
* @see org.apache.sling.api.servlets.SlingSafeMethodsServlet#doGet(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.SlingHttpServletResponse)
*/
- @Override
+ @SuppressWarnings("unchecked")
+ @Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
@@ -157,18 +158,20 @@ public class GetAclServlet extends SlingAllMethodsServlet {
}
AccessControlEntry[] declaredAccessControlEntries = getDeclaredAccessControlEntries(session, resourcePath);
- Map<String, Map<String, Set<String>>> aclMap = new LinkedHashMap<String, Map<String,Set<String>>>();
+ Map<String, Map<String, Object>> aclMap = new LinkedHashMap<String, Map<String,Object>>();
+ int sequence = 0;
for (AccessControlEntry ace : declaredAccessControlEntries) {
Principal principal = ace.getPrincipal();
- Map<String, Set<String>> map = aclMap.get(principal.getName());
+ Map<String, Object> map = aclMap.get(principal.getName());
if (map == null) {
- map = new LinkedHashMap<String, Set<String>>();
+ map = new LinkedHashMap<String, Object>();
aclMap.put(principal.getName(), map);
+ map.put("order", sequence++);
}
boolean allow = AccessControlUtil.isAllow(ace);
if (allow) {
- Set<String> grantedSet = map.get("granted");
+ Set<String> grantedSet = (Set<String>) map.get("granted");
if (grantedSet == null) {
grantedSet = new LinkedHashSet<String>();
map.put("granted", grantedSet);
@@ -178,7 +181,7 @@ public class GetAclServlet extends SlingAllMethodsServlet {
grantedSet.add(privilege.getName());
}
} else {
- Set<String> deniedSet = map.get("denied");
+ Set<String> deniedSet = (Set<String>) map.get("denied");
if (deniedSet == null) {
deniedSet = new LinkedHashSet<String>();
map.put("denied", deniedSet);
@@ -195,30 +198,32 @@ public class GetAclServlet extends SlingAllMethodsServlet {
response.setCharacterEncoding("UTF-8");
List<JSONObject> aclList = new ArrayList<JSONObject>();
- Set<Entry<String, Map<String, Set<String>>>> entrySet = aclMap.entrySet();
- for (Entry<String, Map<String, Set<String>>> entry : entrySet) {
+ Set<Entry<String, Map<String, Object>>> entrySet = aclMap.entrySet();
+ for (Entry<String, Map<String, Object>> entry : entrySet) {
String principalName = entry.getKey();
- Map<String, Set<String>> value = entry.getValue();
+ Map<String, Object> value = entry.getValue();
JSONObject aceObject = new JSONObject();
aceObject.put("principal", principalName);
- Set<String> grantedSet = value.get("granted");
+ Set<String> grantedSet = (Set<String>) value.get("granted");
if (grantedSet != null) {
aceObject.put("granted", grantedSet);
}
- Set<String> deniedSet = value.get("denied");
+ Set<String> deniedSet = (Set<String>) value.get("denied");
if (deniedSet != null) {
aceObject.put("denied", deniedSet);
}
-
+ aceObject.put("order", value.get("order"));
aclList.add(aceObject);
}
- JSONArray jsonAclArray = new JSONArray(aclList);
-
+ JSONObject jsonAclMap = new JSONObject(aclMap);
+ for ( JSONObject jsonObj : aclList) {
+ jsonAclMap.put(jsonObj.getString("principal"), jsonObj);
+ }
+ jsonAclMap.write(response.getWriter());
// do the dump
- jsonAclArray.write(response.getWriter());
} catch (AccessDeniedException ade) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (ResourceNotFoundException rnfe) {
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 15/24:
SLING-1677 Let AccessManager POST servlets return JSON
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 51205d631969589a89f93129ae30ff49ac395ef2
Author: Eric Norman <en...@apache.org>
AuthorDate: Tue Aug 24 04:36:33 2010 +0000
SLING-1677 Let AccessManager POST servlets return JSON
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@988382 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 9 ++++++++-
.../post/AbstractAccessPostServlet.java | 20 +++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 8c0ef3a..9ddaffe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,9 @@
<instructions>
<Private-Package>
</Private-Package>
+ <Embed-Dependency>
+ org.apache.sling.servlets.post;inline="org/apache/sling/servlets/post/impl/helper/JSONResponse*"
+ </Embed-Dependency>
<Export-Package>
org.apache.sling.jcr.jackrabbit.accessmanager;version=${project.version},
org.apache.sling.jcr.jackrabbit.accessmanager.post;version=${project.version}
@@ -114,7 +117,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.post</artifactId>
- <version>2.0.4-incubator</version>
+ <version>2.0.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -137,5 +140,9 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
index e13b179..7d87b79 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/AbstractAccessPostServlet.java
@@ -39,6 +39,7 @@ import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.api.wrappers.SlingRequestPaths;
import org.apache.sling.servlets.post.Modification;
import org.apache.sling.servlets.post.SlingPostConstants;
+import org.apache.sling.servlets.post.impl.helper.JSONResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -61,7 +62,7 @@ public abstract class AbstractAccessPostServlet extends SlingAllMethodsServlet {
SlingHttpServletResponse httpResponse) throws ServletException,
IOException {
// prepare the response
- HtmlResponse htmlResponse = new HtmlResponse();
+ HtmlResponse htmlResponse = createHtmlResponse(request);
htmlResponse.setReferer(request.getHeader("referer"));
// calculate the paths
@@ -133,6 +134,23 @@ public abstract class AbstractAccessPostServlet extends SlingAllMethodsServlet {
htmlResponse.send(httpResponse, isSetStatus(request));
}
+ /**
+ * Creates an instance of a HtmlResponse.
+ * @param req The request being serviced
+ * @return a {@link org.apache.sling.servlets.post.impl.helper.JSONResponse} if any of these conditions are true:
+ * <ul>
+ * <li>the response content type is application/json
+ * </ul>
+ * or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise
+ */
+ protected HtmlResponse createHtmlResponse(SlingHttpServletRequest req) {
+ if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) {
+ return new JSONResponse();
+ } else {
+ return new HtmlResponse();
+ }
+ }
+
/**
* Extending Servlet should implement this operation to do the work
*
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 18/24: tabs
-> spaces
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 90384816b8525390fd49d91fffc018188ad67dc7
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Sep 10 14:53:40 2010 +0000
tabs -> spaces
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@995813 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 190 ++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 95 insertions(+), 95 deletions(-)
diff --git a/pom.xml b/pom.xml
index f2784a4..c102ea0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,82 +19,82 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
<version>9</version>
- <relativePath>../../../parent/pom.xml</relativePath>
- </parent>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
- <artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId>
- <packaging>bundle</packaging>
- <version>2.0.5-SNAPSHOT</version>
- <name>Apache Sling Jackrabbit JSR-283 Access Control Manager Support</name>
- <description>
- Provides SlingPostOperations for the Jackrabbit JSR-283 Access Control Manager.
- </description>
+ <artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId>
+ <packaging>bundle</packaging>
+ <version>2.0.5-SNAPSHOT</version>
+ <name>Apache Sling Jackrabbit JSR-283 Access Control Manager Support</name>
+ <description>
+ Provides SlingPostOperations for the Jackrabbit JSR-283 Access Control Manager.
+ </description>
- <scm>
- <connection>
- scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
- </connection>
- <developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
- </developerConnection>
- <url>
- http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-accessmanager
- </url>
- </scm>
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ </developerConnection>
+ <url>
+ http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ </url>
+ </scm>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Private-Package>
- </Private-Package>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Private-Package>
+ </Private-Package>
<Embed-Dependency>
org.apache.sling.servlets.post;inline="org/apache/sling/servlets/post/impl/helper/JSONResponse*"
</Embed-Dependency>
- <Export-Package>
+ <Export-Package>
org.apache.sling.jcr.jackrabbit.accessmanager;version=2.0.6,
org.apache.sling.jcr.jackrabbit.accessmanager.post;version=2.0.6
- </Export-Package>
- <Sling-Initial-Content />
- <Sling-Nodetypes />
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ </Export-Package>
+ <Sling-Initial-Content />
+ <Sling-Nodetypes />
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <!-- No javadocs -->
- <excludePackageNames>
- </excludePackageNames>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <!-- No javadocs -->
+ <excludePackageNames>
+ </excludePackageNames>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
@@ -102,47 +102,47 @@
<version>2.0.4-incubator</version>
</dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.0.8</version>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.0.8</version>
<scope>provided</scope>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.servlets.post</artifactId>
- <version>2.0.5-SNAPSHOT</version>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlets.post</artifactId>
+ <version>2.0.5-SNAPSHOT</version>
<scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
<scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.base</artifactId>
- <version>2.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.base</artifactId>
+ <version>2.1.0</version>
<scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- </dependencies>
+ </dependencies>
</project>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 11/24: Use
released parent pom.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit f66de82a082fe8b5eea8e868ad989c4b4dc5c07d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon May 17 13:42:29 2010 +0000
Use released parent pom.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@945149 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index d0694c5..8c0ef3a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>8</version>
+ <version>9</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 05/24:
SLING-1411 Add replaceAccessControlEntry method to AccessControlUtil Thanks
to Ray Davis for the contribution.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 533a4bad82a9402b1526c9d8d9de94f0ff60793d
Author: Eric Norman <en...@apache.org>
AuthorDate: Sat Feb 27 02:02:09 2010 +0000
SLING-1411 Add replaceAccessControlEntry method to AccessControlUtil
Thanks to Ray Davis for the contribution.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@916893 13f79535-47bb-0310-9956-ffa450edef68
---
.../accessmanager/post/ModifyAceServlet.java | 370 +++------------------
1 file changed, 44 insertions(+), 326 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index 432387e..d9e998a 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -16,8 +16,15 @@
*/
package org.apache.sling.jcr.jackrabbit.accessmanager.post;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceNotFoundException;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.jcr.base.util.AccessControlUtil;
+import org.apache.sling.servlets.post.Modification;
+
import java.security.Principal;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
@@ -26,31 +33,16 @@ import java.util.Set;
import javax.jcr.Item;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import javax.jcr.security.AccessControlEntry;
-import javax.jcr.security.AccessControlList;
-import javax.jcr.security.AccessControlManager;
-import javax.jcr.security.Privilege;
-
-import org.apache.jackrabbit.api.security.user.Authorizable;
-import org.apache.jackrabbit.api.security.user.UserManager;
-import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceNotFoundException;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.jcr.base.util.AccessControlUtil;
-import org.apache.sling.servlets.post.Modification;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* <p>
- * Sling Post Servlet implementation for modifying the ACE for a principal on a JCR
+ * Sling Post Servlet implementation for modifying the ACEs for a principal on a JCR
* resource.
* </p>
* <h2>Rest Service Description</h2>
* <p>
- * Delete a set of Ace's from a node, the node is identified as a resource by the request
- * url >resource<.modifyAce.html
+ * Modify a principal's ACEs for the node identified as a resource by the request
+ * URL >resource<.modifyAce.html
* </p>
* <h4>Methods</h4>
* <ul>
@@ -59,11 +51,11 @@ import org.slf4j.LoggerFactory;
* <h4>Post Parameters</h4>
* <dl>
* <dt>principalId</dt>
- * <dd>The principal of the Ace to modify in the ACL specified by the path.</dd>
+ * <dd>The principal of the ACEs to modify in the ACL specified by the path.</dd>
* <dt>privilege@*</dt>
- * <dd>One of more privileges, either granted or denied, where set the permission in the
- * stored ACE is modified to match the request. Any permissions that are present in the
- * stored ACE, but are not in the request are left untouched.</dd>
+ * <dd>One or more privileges, either granted or denied or none, which will be applied
+ * to (or removed from) the node ACL. Any permissions that are present in an
+ * existing ACE for the principal but not in the request are left untouched.</dd>
* </dl>
*
* <h4>Response</h4>
@@ -92,11 +84,6 @@ import org.slf4j.LoggerFactory;
public class ModifyAceServlet extends AbstractAccessPostServlet {
private static final long serialVersionUID = -9182485466670280437L;
- /**
- * default log
- */
- private final Logger log = LoggerFactory.getLogger(getClass());
-
/* (non-Javadoc)
* @see org.apache.sling.jackrabbit.accessmanager.post.AbstractAccessPostServlet#handleOperation(org.apache.sling.api.SlingHttpServletRequest, org.apache.sling.api.servlets.HtmlResponse, java.util.List)
*/
@@ -113,88 +100,25 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
if (principalId == null) {
throw new RepositoryException("principalId was not submitted.");
}
- UserManager userManager = AccessControlUtil.getUserManager(session);
- Authorizable authorizable = userManager.getAuthorizable(principalId);
- if (authorizable == null) {
- throw new RepositoryException("No principal found for id: " + principalId);
- }
-
- String resourcePath = null;
- Resource resource = request.getResource();
- if (resource == null) {
+ PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
+ Principal principal = principalManager.getPrincipal(principalId);
+ String resourcePath = null;
+ Resource resource = request.getResource();
+ if (resource == null) {
throw new ResourceNotFoundException("Resource not found.");
- } else {
- Item item = resource.adaptTo(Item.class);
- if (item != null) {
- resourcePath = item.getPath();
- } else {
- throw new ResourceNotFoundException("Resource is not a JCR Node");
- }
- }
-
- try {
- AccessControlManager accessControlManager = AccessControlUtil.getAccessControlManager(session);
-
- //SLING-997: keep track of the privilege names that were posted, so the others can be preserved
- PrivilegesState privilegesInfo = new PrivilegesState(log.isDebugEnabled());
-
- //calculate which privileges were POSTed.
- collectPostedPrivilegeNames(request,
- accessControlManager,
- privilegesInfo);
-
- //find the existing ACL
- AccessControlList updatedAcl = getAccessControlList(accessControlManager, resourcePath, true);
-
- //keep track of the existing ACEs for the target principal
- List<AccessControlEntry> oldAces = processExistingAccessControlEntries(resourcePath,
- authorizable,
- accessControlManager,
- updatedAcl,
- privilegesInfo);
-
- //remove the old ACEs. Re-created below.
- if (!oldAces.isEmpty()) {
- for (AccessControlEntry ace : oldAces) {
- updatedAcl.removeAccessControlEntry(ace);
- }
+ } else {
+ Item item = resource.adaptTo(Item.class);
+ if (item != null) {
+ resourcePath = item.getPath();
+ } else {
+ throw new ResourceNotFoundException("Resource is not a JCR Node");
}
-
- //re-aggregate the granted/denied privileges into the best matched aggregate privilege
- reaggregatePrivileges(resourcePath,
- accessControlManager,
- privilegesInfo);
-
- //add fresh ACEs with the granted privileges
- buildFreshAccessControlEntries(authorizable,
- accessControlManager,
- updatedAcl,
- privilegesInfo);
-
- //store the updated ACL
- accessControlManager.setPolicy(resourcePath, updatedAcl);
- if (session.hasPendingChanges()) {
- session.save();
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Updated ACE for principalId {0} for resource {1) from {2} to {3}", new Object [] {
- authorizable.getID(), resourcePath, privilegesInfo.oldPrivileges.toString(), privilegesInfo.newPrivileges.toString()
- });
- }
- } catch (RepositoryException re) {
- throw new RepositoryException("Failed to create ace.", re);
}
- }
-
-
- /**
- * Collect the privileges to assign from the http request.
- */
- private void collectPostedPrivilegeNames(SlingHttpServletRequest request,
- AccessControlManager accessControlManager,
- PrivilegesState privilegesInfo) throws RepositoryException {
-
+
+ // Collect the modified privileges from the request.
+ Set<String> grantedPrivilegeNames = new HashSet<String>();
+ Set<String> deniedPrivilegeNames = new HashSet<String>();
+ Set<String> removedPrivilegeNames = new HashSet<String>();
Enumeration<?> parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
Object nextElement = parameterNames.nextElement();
@@ -202,237 +126,31 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
String paramName = (String)nextElement;
if (paramName.startsWith("privilege@")) {
String privilegeName = paramName.substring(10);
- //keep track of which privileges should be changed
- privilegesInfo.postedPrivilegeNames.add(privilegeName);
-
String parameterValue = request.getParameter(paramName);
if (parameterValue != null && parameterValue.length() > 0) {
if ("granted".equals(parameterValue)) {
- Privilege privilege = accessControlManager.privilegeFromName(privilegeName);
- if (privilege.isAggregate()) {
- Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
- for (Privilege privilege2 : aggregatePrivileges) {
- privilegesInfo.grantedPrivilegeNames.add(privilege2.getName());
- }
- } else {
- privilegesInfo.grantedPrivilegeNames.add(privilegeName);
- }
+ grantedPrivilegeNames.add(privilegeName);
} else if ("denied".equals(parameterValue)) {
- Privilege privilege = accessControlManager.privilegeFromName(privilegeName);
- if (privilege.isAggregate()) {
- Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
- for (Privilege privilege2 : aggregatePrivileges) {
- privilegesInfo.deniedPrivilegeNames.add(privilege2.getName());
- }
- } else {
- privilegesInfo.deniedPrivilegeNames.add(privilegeName);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Process the existing ACL to determine which privileges to preserve.
- */
- private List<AccessControlEntry> processExistingAccessControlEntries(
- String resourcePath,
- Authorizable authorizable,
- AccessControlManager accessControlManager,
- AccessControlList updatedAcl,
- PrivilegesState privilegesInfo) throws RepositoryException {
-
- String principalId = authorizable.getPrincipal().getName();
- AccessControlEntry[] accessControlEntries = updatedAcl.getAccessControlEntries();
- List<AccessControlEntry> oldAces = new ArrayList<AccessControlEntry>();
- for (AccessControlEntry ace : accessControlEntries) {
- if (principalId.equals(ace.getPrincipal().getName())) {
- if (log.isDebugEnabled()) {
- log.debug("Found Existing ACE for principal {0} on resource: ", new Object[] {principalId, resourcePath});
- }
- oldAces.add(ace);
-
- boolean isAllow = AccessControlUtil.isAllow(ace);
- Privilege[] privileges = ace.getPrivileges();
-
- //build a list of (merged and expanded) privileges
- Set<Privilege> mergedExistingPrivileges = new HashSet<Privilege>();
- for (Privilege privilege : privileges) {
- if (privilege.isAggregate()) {
- Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
- for (Privilege privilege2 : aggregatePrivileges) {
- mergedExistingPrivileges.add(privilege2);
- }
- } else {
- mergedExistingPrivileges.add(privilege);
- }
- }
-
- //now process the merged privileges set
- for (Privilege privilege : mergedExistingPrivileges) {
- String privilegeName = privilege.getName();
- if (!privilegesInfo.postedPrivilegeNames.contains(privilegeName)) {
- //this privilege was not posted, so record the existing state to be
- // preserved when the ACE is re-created below
- if (isAllow) {
- privilegesInfo.grantedPrivilegeNames.add(privilegeName);
- } else {
- privilegesInfo.deniedPrivilegeNames.add(privilegeName);
- }
- }
-
- if (log.isDebugEnabled()) {
- //collect the information for debug logging
- if (privilegesInfo.oldPrivileges.length() > 0) {
- privilegesInfo.oldPrivileges.append(", "); //separate entries by commas
- }
- if (isAllow) {
- privilegesInfo.oldPrivileges.append("granted=");
+ deniedPrivilegeNames.add(privilegeName);
} else {
- privilegesInfo.oldPrivileges.append("denied=");
+ removedPrivilegeNames.add(privilegeName);
}
- privilegesInfo.oldPrivileges.append(privilege.getName());
- }
- }
- }
- }
-
- return oldAces;
- }
-
- /**
- * Given the set of granted/denied privileges, try to combine them
- * into the best aggregate Privilege that contains them all.
- */
- private void reaggregatePrivileges(
- String resourcePath,
- AccessControlManager accessControlManager,
- PrivilegesState privilegesInfo) throws RepositoryException {
- Privilege[] supportedPrivileges = accessControlManager.getSupportedPrivileges(resourcePath);
- for (Privilege privilege : supportedPrivileges) {
- if (privilege.isAggregate()) {
- boolean grantedAggregatePrivilege = true;
- boolean deniedAggregatePrivilege = true;
- Privilege[] aggregatePrivileges = privilege.getAggregatePrivileges();
- for (Privilege privilege2 : aggregatePrivileges) {
- String name = privilege2.getName();
- if (!privilegesInfo.grantedPrivilegeNames.contains(name)) {
- grantedAggregatePrivilege = false;
- }
- if (!privilegesInfo.deniedPrivilegeNames.contains(name)) {
- deniedAggregatePrivilege = false;
- }
- }
-
- if (grantedAggregatePrivilege) {
- //add the aggregate privilege and remove the containing parts
- privilegesInfo.grantedPrivilegeNames.add(privilege.getName());
- for (Privilege privilege2 : aggregatePrivileges) {
- String name = privilege2.getName();
- privilegesInfo.grantedPrivilegeNames.remove(name);
- }
- }
-
- if (deniedAggregatePrivilege) {
- //add the aggregate privilege and remove the containing parts
- privilegesInfo.deniedPrivilegeNames.add(privilege.getName());
- for (Privilege privilege2 : aggregatePrivileges) {
- String name = privilege2.getName();
- privilegesInfo.deniedPrivilegeNames.remove(name);
- }
- }
- }
- }
- }
-
- /**
- * Create new ACE for the granted and denied privileges.
- */
- private void buildFreshAccessControlEntries(
- Authorizable authorizable,
- AccessControlManager accessControlManager,
- AccessControlList updatedAcl,
- PrivilegesState privilegesInfo) throws RepositoryException {
- List<Privilege> grantedPrivilegeList = new ArrayList<Privilege>();
- for (String name : privilegesInfo.grantedPrivilegeNames) {
- if (name.length() == 0) {
- continue; //empty, skip it.
- }
- Privilege privilege = accessControlManager.privilegeFromName(name);
- grantedPrivilegeList.add(privilege);
- }
-
- if (log.isDebugEnabled()) {
- for (Privilege privilege : grantedPrivilegeList) {
- if (privilegesInfo.newPrivileges.length() > 0) {
- privilegesInfo.newPrivileges.append(", "); //separate entries by commas
- }
- privilegesInfo.newPrivileges.append("granted=");
- privilegesInfo.newPrivileges.append(privilege.getName());
- }
- }
-
- if (grantedPrivilegeList.size() > 0) {
- Principal principal = authorizable.getPrincipal();
- updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
- }
-
- //if the authorizable is a user (not a group) process any denied privileges
- if (!authorizable.isGroup()) {
- //add a fresh ACE with the denied privileges
- List<Privilege> deniedPrivilegeList = new ArrayList<Privilege>();
- for (String name : privilegesInfo.deniedPrivilegeNames) {
- if (name.length() == 0) {
- continue; //empty, skip it.
- }
- Privilege privilege = accessControlManager.privilegeFromName(name);
- deniedPrivilegeList.add(privilege);
- }
-
- if (log.isDebugEnabled()) {
- for (Privilege privilege : deniedPrivilegeList) {
- if (privilegesInfo.newPrivileges.length() > 0) {
- privilegesInfo.newPrivileges.append(", "); //separate entries by commas
}
- privilegesInfo.newPrivileges.append("denied=");
- privilegesInfo.newPrivileges.append(privilege.getName());
}
}
-
- if (deniedPrivilegeList.size() > 0) {
- Principal principal = authorizable.getPrincipal();
- AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);
- }
}
- }
-
- /**
- * Contains the information about the privilege state as it
- * progresses through the update process.
- */
- private static class PrivilegesState {
- //stores the names of the privileges that were POSTed
- Set<String> postedPrivilegeNames = new HashSet<String>();
-
- //stores the names of the privileges to be granted
- Set<String> grantedPrivilegeNames = new HashSet<String>();
-
- //stores the names of the privileges to be denied
- Set<String> deniedPrivilegeNames = new HashSet<String>();
-
- //collects debug information about the previous privileges
- StringBuilder oldPrivileges = null;
-
- //collects debug information about the new privileges
- StringBuilder newPrivileges = null;
- public PrivilegesState(boolean isDebugEnabled) {
- if (isDebugEnabled) {
- oldPrivileges = new StringBuilder();
- newPrivileges = new StringBuilder();
+ // Make the actual changes.
+ try {
+ AccessControlUtil.replaceAccessControlEntry(session, resourcePath, principal,
+ grantedPrivilegeNames.toArray(new String[grantedPrivilegeNames.size()]),
+ deniedPrivilegeNames.toArray(new String[deniedPrivilegeNames.size()]),
+ removedPrivilegeNames.toArray(new String[removedPrivilegeNames.size()]));
+ if (session.hasPendingChanges()) {
+ session.save();
}
+ } catch (RepositoryException re) {
+ throw new RepositoryException("Failed to create ace.", re);
}
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 17/24:
updating to released jcr bundles
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 1810e04e2e663dfdbc5033ef52a331240ba60a81
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Sep 10 14:53:32 2010 +0000
updating to released jcr bundles
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@995812 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 6af1d23..f2784a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,7 +129,7 @@
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.base</artifactId>
- <version>2.0.7-SNAPSHOT</version>
+ <version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 06/24:
SLING-1411 Clarify how to un-set a privilege and fix the sample ACE edit
script from the launchpad.content bundle
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit b866e1d613e8d63ba65ffa860d4b92b19ce6f928
Author: Eric Norman <en...@apache.org>
AuthorDate: Sat Feb 27 18:32:52 2010 +0000
SLING-1411 Clarify how to un-set a privilege and fix the sample ACE edit script from the launchpad.content bundle
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@917006 13f79535-47bb-0310-9956-ffa450edef68
---
.../sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index d9e998a..73718e6 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -132,7 +132,7 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
grantedPrivilegeNames.add(privilegeName);
} else if ("denied".equals(parameterValue)) {
deniedPrivilegeNames.add(privilegeName);
- } else {
+ } else if ("none".equals(parameterValue)){
removedPrivilegeNames.add(privilegeName);
}
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 23/24:
[maven-release-plugin] prepare release
org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit b67cc191b5ce055181128aedb484ab9fe296797a
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Wed Nov 3 17:52:42 2010 +0000
[maven-release-plugin] prepare release org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@1030567 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index ba5abb6..917a271 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
<artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId>
<packaging>bundle</packaging>
- <version>2.0.5-SNAPSHOT</version>
+ <version>2.1.0</version>
<name>Apache Sling Jackrabbit JSR-283 Access Control Manager Support</name>
<description>
Provides SlingPostOperations for the Jackrabbit JSR-283 Access Control Manager.
@@ -37,13 +37,13 @@
<scm>
<connection>
- scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
</connection>
<developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
</developerConnection>
<url>
- http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-accessmanager
+ http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
</url>
</scm>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 03/24:
SLING-997 ModifyAceServlet replaces rather than merges privileges
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git
commit 4a1834417183b1f6e5646c6023c146b3c3bd495b
Author: Eric Norman <en...@apache.org>
AuthorDate: Sun Feb 21 18:37:45 2010 +0000
SLING-997 ModifyAceServlet replaces rather than merges privileges
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@912387 13f79535-47bb-0310-9956-ffa450edef68
---
.../accessmanager/post/ModifyAceServlet.java | 58 +++++++++++++++-------
1 file changed, 41 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
index b8efad6..ac3577a 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/post/ModifyAceServlet.java
@@ -19,7 +19,9 @@ package org.apache.sling.jcr.jackrabbit.accessmanager.post;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.jcr.Item;
import javax.jcr.RepositoryException;
@@ -134,19 +136,23 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
List<String> grantedPrivilegeNames = new ArrayList<String>();
List<String> deniedPrivilegeNames = new ArrayList<String>();
+ //SLING-997: keep track of the privilege names that were posted, so the others can be preserved
+ Set<String> postedPrivilegeNames = new HashSet<String>();
Enumeration parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements()) {
Object nextElement = parameterNames.nextElement();
if (nextElement instanceof String) {
String paramName = (String)nextElement;
if (paramName.startsWith("privilege@")) {
+ String privilegeName = paramName.substring(10);
+ //keep track of which privileges should be changed
+ postedPrivilegeNames.add(privilegeName);
+
String parameterValue = request.getParameter(paramName);
if (parameterValue != null && parameterValue.length() > 0) {
if ("granted".equals(parameterValue)) {
- String privilegeName = paramName.substring(10);
grantedPrivilegeNames.add(privilegeName);
} else if ("denied".equals(parameterValue)) {
- String privilegeName = paramName.substring(10);
deniedPrivilegeNames.add(privilegeName);
}
}
@@ -165,6 +171,9 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
newPrivileges = new StringBuilder();
}
+ List<Privilege> preserveGrantedPrivileges = new ArrayList<Privilege>();
+ List<Privilege> preserveDeniedPrivileges = new ArrayList<Privilege>();
+
//keep track of the existing Aces for the target principal
AccessControlEntry[] accessControlEntries = updatedAcl.getAccessControlEntries();
List<AccessControlEntry> oldAces = new ArrayList<AccessControlEntry>();
@@ -175,20 +184,25 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
}
oldAces.add(ace);
- if (log.isDebugEnabled()) {
- //collect the information for debug logging
- boolean isAllow = AccessControlUtil.isAllow(ace);
- Privilege[] privileges = ace.getPrivileges();
- for (Privilege privilege : privileges) {
- if (oldPrivileges.length() > 0) {
- oldPrivileges.append(", "); //separate entries by commas
- }
+ boolean isAllow = AccessControlUtil.isAllow(ace);
+ Privilege[] privileges = ace.getPrivileges();
+ for (Privilege privilege : privileges) {
+ String privilegeName = privilege.getName();
+ if (!postedPrivilegeNames.contains(privilegeName)) {
+ //this privilege was not posted, so record the existing state to be
+ // preserved when the ACE is re-created below
if (isAllow) {
- oldPrivileges.append("granted=");
+ preserveGrantedPrivileges.add(privilege);
} else {
- oldPrivileges.append("denied=");
+ preserveDeniedPrivileges.add(privilege);
+ }
+ }
+
+ if (log.isDebugEnabled()) {
+ //collect the information for debug logging
+ if (oldPrivileges.length() > 0) {
+ oldPrivileges.append(", "); //separate entries by commas
}
- oldPrivileges.append(privilege.getName());
}
}
}
@@ -209,15 +223,20 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
}
Privilege privilege = accessControlManager.privilegeFromName(name);
grantedPrivilegeList.add(privilege);
+ }
+ //add the privileges that should be preserved
+ grantedPrivilegeList.addAll(preserveGrantedPrivileges);
- if (log.isDebugEnabled()) {
+ if (log.isDebugEnabled()) {
+ for (Privilege privilege : grantedPrivilegeList) {
if (newPrivileges.length() > 0) {
newPrivileges.append(", "); //separate entries by commas
}
newPrivileges.append("granted=");
newPrivileges.append(privilege.getName());
- }
+ }
}
+
if (grantedPrivilegeList.size() > 0) {
Principal principal = authorizable.getPrincipal();
updatedAcl.addAccessControlEntry(principal, grantedPrivilegeList.toArray(new Privilege[grantedPrivilegeList.size()]));
@@ -233,8 +252,12 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
}
Privilege privilege = accessControlManager.privilegeFromName(name);
deniedPrivilegeList.add(privilege);
-
- if (log.isDebugEnabled()) {
+ }
+ //add the privileges that should be preserved
+ deniedPrivilegeList.addAll(preserveDeniedPrivileges);
+
+ if (log.isDebugEnabled()) {
+ for (Privilege privilege : deniedPrivilegeList) {
if (newPrivileges.length() > 0) {
newPrivileges.append(", "); //separate entries by commas
}
@@ -242,6 +265,7 @@ public class ModifyAceServlet extends AbstractAccessPostServlet {
newPrivileges.append(privilege.getName());
}
}
+
if (deniedPrivilegeList.size() > 0) {
Principal principal = authorizable.getPrincipal();
AccessControlUtil.addEntry(updatedAcl, principal, deniedPrivilegeList.toArray(new Privilege[deniedPrivilegeList.size()]), false);
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.