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:49:08 UTC

[sling-org-apache-sling-jcr-resourcesecurity] annotated tag org.apache.sling.jcr.resourcesecurity-1.0.0 created (now 0b186c4)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.jcr.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git.


      at 0b186c4  (tag)
 tagging a4eeae5df919ecf81b19a4f9f23fd9359b1c20fd (commit)
      by Carsten Ziegeler
      on Mon Jan 5 15:52:03 2015 +0000

- Log -----------------------------------------------------------------
org.apache.sling.jcr.resourcesecurity-1.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 4e46e64  Add new project containing an access security gate which protectes resource providers based on JCR nodes.
     new b2bed21  SLING-2698 - resource access security service for resource providers. Distinguish between context application and provider
     new 10e45a8  Use released Sling API
     new 3dc5786  Don't apply gate if the resource is a jcr resource
     new 9615f3d  SLING-3438 : Provide ResourceAccessGate implementation that authorizes CRUD operations based on JCR permissios. Merge patch from Marius Petria with existing implementation
     new 52af11e  Simplify code, use common method for permission check
     new 27da478  Simplify code, use common method for permission check
     new 8da3219  Implement deep structure check based on the resource path
     new 7c9f63a  Update to parent pom v19
     new b51755c  Update to latest parent pom 20
     new a4ef095  Update to Sling Parent POM 22 with baselining enabled
     new bc2195d  Use released resourceacesssecurity
     new 6d6c765  [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.0
     new 67919f3  Correct svn info
     new 2cbe7c6  [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.0
     new a4eeae5  [maven-release-plugin]  copy for tag org.apache.sling.jcr.resourcesecurity-1.0.0

The 16 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-resourcesecurity] 14/16: Correct svn info

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 67919f3faeb47a3d42e9c190adec0cd0828d3b87
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 15:51:29 2015 +0000

    Correct svn info
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1649558 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 892e42e..62bf159 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.resourcesecurity</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling JCR Resource Security</name>
@@ -36,9 +36,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/jcr/resourcesecurity</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 10/16: Update to latest parent pom 20

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit b51755cb57eb18870e73f5c541205dc179eb3492
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Sep 2 14:50:33 2014 +0000

    Update to latest parent pom 20
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1622029 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 00120f5..916a70a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>19</version>
+        <version>20</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-resourcesecurity] 04/16: Don't apply gate if the resource is a jcr resource

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 3dc57864d3dc9049db3c7c34a47a86dc69d7a03e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jan 29 11:05:47 2014 +0000

    Don't apply gate if the resource is a jcr resource
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1562400 13f79535-47bb-0310-9956-ffa450edef68
---
 .../jcr/resourcesecurity/impl/ResourceAccessGateFactory.java     | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index d102234..eab7816 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -20,6 +20,7 @@ package org.apache.sling.jcr.resourcesecurity.impl;
 
 import java.util.Map;
 
+import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -69,8 +70,16 @@ public class ResourceAccessGateFactory
         return true;
     }
 
+    private boolean skipCheck(final Resource resource) {
+        // if resource is backed by a jcr node, skip check
+        return resource.adaptTo(Node.class) != null;
+    }
+
     @Override
     public GateResult canRead(final Resource resource) {
+        if ( this.skipCheck(resource) ) {
+            return GateResult.GRANTED;
+        }
         final Session session = resource.getResourceResolver().adaptTo(Session.class);
         boolean canRead = false;
         if ( session != null ) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 08/16: Implement deep structure check based on the resource path

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 8da3219ba5649c509727d89d780e92a25488deda
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 28 16:54:19 2014 +0000

    Implement deep structure check based on the resource path
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1582823 13f79535-47bb-0310-9956-ffa450edef68
---
 .../jcr/resourcesecurity/impl/ResourceAccessGateFactory.java | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index 6d9c5e2..2b7d253 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -67,9 +67,15 @@ public class ResourceAccessGateFactory
 
     private String jcrPath;
 
+    private String prefix;
+
     @Activate
     protected void activate(final Map<String, Object> props) {
         this.jcrPath = PropertiesUtil.toString(props.get(PROP_JCR_PATH), null);
+        this.prefix = PropertiesUtil.toString(props.get(PROP_PREFIX), null);
+        if ( !this.prefix.endsWith("/") ) {
+            this.prefix = this.prefix + "/";
+        }
     }
 
     /**
@@ -81,8 +87,12 @@ public class ResourceAccessGateFactory
         boolean granted = false;
         final Session session = resolver.adaptTo(Session.class);
         if ( session != null ) {
+            String checkPath = this.jcrPath;
+            if ( this.prefix != null && path.startsWith(this.prefix) ) {
+                checkPath = this.jcrPath + path.substring(this.prefix.length() - 1);
+            }
             try {
-                granted = session.hasPermission(jcrPath, permission);
+                granted = session.hasPermission(checkPath, permission);
             } catch (final RepositoryException re) {
                 // ignore
             }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 15/16: [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 2cbe7c6fbc0c1a76d5eaad169f25b620b947e718
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 15:51:51 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1649559 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 62bf159..892e42e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.resourcesecurity</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling JCR Resource Security</name>
@@ -36,9 +36,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/jcr/resourcesecurity</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 13/16: [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 6d6c765ee5360c1ef4b7c51cc080f8386076c161
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 15:49:26 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.jcr.resourcesecurity-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1649556 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1bf4504..892e42e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
     </parent>
 
     <artifactId>org.apache.sling.jcr.resourcesecurity</artifactId>
-    <version>0.0.1-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling JCR Resource Security</name>
@@ -36,9 +36,9 @@
     </description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resourcesecurity</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resourcesecurity</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resourcesecurity</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 02/16: SLING-2698 - resource access security service for resource providers. Distinguish between context application and provider

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit b2bed2101a1df4f6621e2a4a3d46ec1e7013206e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jan 16 10:04:39 2014 +0000

    SLING-2698 - resource access security service for resource providers. Distinguish between context application and provider
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1558733 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index 9309733..d102234 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -48,7 +48,8 @@ import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
     @Property(name=ResourceAccessGateFactory.PROP_JCR_PATH,
               label="JCR Node",
               description="This node is checked for permissions to the resources."),
-    @Property(name=ResourceAccessGate.OPERATIONS, value="read", propertyPrivate=true)
+    @Property(name=ResourceAccessGate.OPERATIONS, value="read", propertyPrivate=true),
+    @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.PROVIDER_CONTEXT, propertyPrivate=true)
 })
 public class ResourceAccessGateFactory
     extends AllowingResourceAccessGate

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 09/16: Update to parent pom v19

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 7c9f63a485031f33a18f04ab304fa5858f847a0c
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Mar 31 14:39:20 2014 +0000

    Update to parent pom v19
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1583337 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index ace06fc..00120f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>18</version>
+        <version>19</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-resourcesecurity] 05/16: SLING-3438 : Provide ResourceAccessGate implementation that authorizes CRUD operations based on JCR permissios. Merge patch from Marius Petria with existing implementation

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 9615f3d4c50184c8dca6bcc218c18c8164b58a5f
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 28 16:30:00 2014 +0000

    SLING-3438 : Provide ResourceAccessGate implementation that authorizes CRUD operations based on JCR permissios. Merge patch from Marius Petria with existing implementation
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1582808 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/ResourceAccessGateFactory.java            | 111 +++++++++++++++++++--
 1 file changed, 105 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index eab7816..e9ba073 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -36,7 +36,6 @@ import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate;
 import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
 
-
 @Component(configurationFactory=true, policy=ConfigurationPolicy.REQUIRE, metatype=true,
            label="Apache Sling JCR Resource Access Gate",
            description="This access gate can be used to handle the access to resources" +
@@ -49,7 +48,7 @@ import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
     @Property(name=ResourceAccessGateFactory.PROP_JCR_PATH,
               label="JCR Node",
               description="This node is checked for permissions to the resources."),
-    @Property(name=ResourceAccessGate.OPERATIONS, value="read", propertyPrivate=true),
+    @Property(name=ResourceAccessGate.OPERATIONS, value= {"read", "create", "update", "delete"}, propertyPrivate=true),
     @Property(name=ResourceAccessGate.CONTEXT, value=ResourceAccessGate.PROVIDER_CONTEXT, propertyPrivate=true)
 })
 public class ResourceAccessGateFactory
@@ -65,16 +64,51 @@ public class ResourceAccessGateFactory
         this.jcrPath = PropertiesUtil.toString(props.get(PROP_JCR_PATH), null);
     }
 
+    /**
+     * Skip the check if the resource is backed by a JCR resource.
+     * This is a sanity check which should usually not be required if the system
+     * is configured correctly.
+     */
+    private boolean skipCheck(final Resource resource) {
+        // if resource is backed by a JCR node, skip check
+        return resource.adaptTo(Node.class) != null;
+    }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#hasReadRestrictions(org.apache.sling.api.resource.ResourceResolver)
+     */
     @Override
-    public boolean hasReadRestrictions(ResourceResolver resourceResolver) {
+    public boolean hasReadRestrictions(final ResourceResolver resourceResolver) {
         return true;
     }
 
-    private boolean skipCheck(final Resource resource) {
-        // if resource is backed by a jcr node, skip check
-        return resource.adaptTo(Node.class) != null;
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#hasCreateRestrictions(org.apache.sling.api.resource.ResourceResolver)
+     */
+    @Override
+    public boolean hasCreateRestrictions(final ResourceResolver resourceResolver) {
+        return true;
+    }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#hasUpdateRestrictions(org.apache.sling.api.resource.ResourceResolver)
+     */
+    @Override
+    public boolean hasUpdateRestrictions(final ResourceResolver resourceResolver) {
+        return true;
+    }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#hasDeleteRestrictions(org.apache.sling.api.resource.ResourceResolver)
+     */
+    @Override
+    public boolean hasDeleteRestrictions(final ResourceResolver resourceResolver) {
+        return true;
     }
 
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#canRead(org.apache.sling.api.resource.Resource)
+     */
     @Override
     public GateResult canRead(final Resource resource) {
         if ( this.skipCheck(resource) ) {
@@ -91,4 +125,69 @@ public class ResourceAccessGateFactory
         }
         return canRead ? GateResult.GRANTED : GateResult.DENIED;
     }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#canDelete(org.apache.sling.api.resource.Resource)
+     */
+    @Override
+    public GateResult canDelete(Resource resource) {
+        if ( this.skipCheck(resource) ) {
+            return GateResult.GRANTED;
+        }
+
+        boolean canDelete = false;
+        final Session session = resource.getResourceResolver().adaptTo(Session.class);
+        if ( session != null ) {
+            try {
+                canDelete = session.hasPermission(jcrPath, Session.ACTION_REMOVE);
+            } catch (final RepositoryException re) {
+                // ignore
+            }
+        }
+
+        return canDelete ? GateResult.GRANTED : GateResult.DENIED;
+
+    }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#canUpdate(org.apache.sling.api.resource.Resource)
+     */
+    @Override
+    public GateResult canUpdate(Resource resource) {
+        if ( this.skipCheck(resource) ) {
+            return GateResult.GRANTED;
+        }
+
+        boolean canUpdate = false;
+
+        final Session session = resource.getResourceResolver().adaptTo(Session.class);
+        if ( session != null ) {
+            try {
+                canUpdate = session.hasPermission(jcrPath, Session.ACTION_SET_PROPERTY);
+            } catch (final RepositoryException re) {
+                // ignore
+            }
+        }
+
+        return canUpdate ? GateResult.GRANTED : GateResult.DENIED;
+    }
+
+    /**
+     * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#canCreate(java.lang.String, org.apache.sling.api.resource.ResourceResolver)
+     */
+    @Override
+    public GateResult canCreate(String absPathName, ResourceResolver resourceResolver) {
+        boolean canCreate = false;
+
+        final Session session = resourceResolver.adaptTo(Session.class);
+        if ( session != null ) {
+            try {
+                canCreate = session.hasPermission(jcrPath, Session.ACTION_ADD_NODE);
+            } catch (final RepositoryException re) {
+                // ignore
+            }
+        }
+
+        return canCreate ? GateResult.GRANTED : GateResult.DENIED;
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 11/16: Update to Sling Parent POM 22 with baselining enabled

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit a4ef09538baadfde446e33155e70c524aa219db0
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 1 06:52:29 2014 +0000

    Update to Sling Parent POM 22 with baselining enabled
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1628620 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 916a70a..145783c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>20</version>
+        <version>22</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-resourcesecurity] 16/16: [maven-release-plugin] copy for tag org.apache.sling.jcr.resourcesecurity-1.0.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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit a4eeae5df919ecf81b19a4f9f23fd9359b1c20fd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 15:52:03 2015 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.jcr.resourcesecurity-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jcr.resourcesecurity-1.0.0@1649560 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-resourcesecurity] 01/16: Add new project containing an access security gate which protectes resource providers based on JCR nodes.

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 4e46e646659ee71f9c2061da6fad0edfccef0565
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Dec 16 04:49:51 2013 +0000

    Add new project containing an access security gate which protectes resource providers based on JCR nodes.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1551115 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 111 +++++++++++++++++++++
 .../impl/ResourceAccessGateFactory.java            |  84 ++++++++++++++++
 2 files changed, 195 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..106280a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<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>
+        <version>18</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.jcr.resourcesecurity</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling JCR Resource Security</name>
+    <description>
+        This bundle provides a resource access gate to protect resources based on JCR nodes.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resourcesecurity</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resourcesecurity</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resourcesecurity</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>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                        org.apache.sling.jcr.resourcesecurity.impl
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+        <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>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <version>2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.4.3-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.resourceaccesssecurity</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
new file mode 100644
index 0000000..9309733
--- /dev/null
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -0,0 +1,84 @@
+/*
+ * 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.resourcesecurity.impl;
+
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.commons.osgi.PropertiesUtil;
+import org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate;
+import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
+
+
+@Component(configurationFactory=true, policy=ConfigurationPolicy.REQUIRE, metatype=true,
+           label="Apache Sling JCR Resource Access Gate",
+           description="This access gate can be used to handle the access to resources" +
+                       " not backed by a JCR repository by providing ACLs in the " +
+                       "reposiory")
+@Service(value=ResourceAccessGate.class)
+@Properties({
+    @Property(name=ResourceAccessGate.PATH, label="Path",
+              description="The path is a regular expression for which resources the service should be called"),
+    @Property(name=ResourceAccessGateFactory.PROP_JCR_PATH,
+              label="JCR Node",
+              description="This node is checked for permissions to the resources."),
+    @Property(name=ResourceAccessGate.OPERATIONS, value="read", propertyPrivate=true)
+})
+public class ResourceAccessGateFactory
+    extends AllowingResourceAccessGate
+    implements ResourceAccessGate {
+
+    static final String PROP_JCR_PATH = "jcrPath";
+
+    private String jcrPath;
+
+    @Activate
+    protected void activate(final Map<String, Object> props) {
+        this.jcrPath = PropertiesUtil.toString(props.get(PROP_JCR_PATH), null);
+    }
+
+    @Override
+    public boolean hasReadRestrictions(ResourceResolver resourceResolver) {
+        return true;
+    }
+
+    @Override
+    public GateResult canRead(final Resource resource) {
+        final Session session = resource.getResourceResolver().adaptTo(Session.class);
+        boolean canRead = false;
+        if ( session != null ) {
+            try {
+                canRead = session.nodeExists(this.jcrPath);
+            } catch (final RepositoryException re) {
+                // ignore
+            }
+        }
+        return canRead ? GateResult.GRANTED : GateResult.DENIED;
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 06/16: Simplify code, use common method for permission check

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 52af11efe13413b33b4cdd0d923ff6cd410987e3
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 28 16:49:25 2014 +0000

    Simplify code, use common method for permission check
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1582820 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/ResourceAccessGateFactory.java            | 76 +++++++++-------------
 1 file changed, 31 insertions(+), 45 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index e9ba073..7c13fed 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -45,6 +45,13 @@ import org.apache.sling.resourceaccesssecurity.ResourceAccessGate;
 @Properties({
     @Property(name=ResourceAccessGate.PATH, label="Path",
               description="The path is a regular expression for which resources the service should be called"),
+    @Property(name=ResourceAccessGateFactory.PROP_PREFIX,
+              label="Deep Check Prefix",
+              description="If this value is configured with a prefix and the resource path starts with this" +
+                          " prefix, the prefix is removed from the path and the remaining part is appended " +
+                          " to the JCR path to check. For example if /foo/a/b/c is required, this prefix is " +
+                          " configured with /foo and the JCR node to check is /check, the permissions at " +
+                          " /check/a/b/c are checked."),
     @Property(name=ResourceAccessGateFactory.PROP_JCR_PATH,
               label="JCR Node",
               description="This node is checked for permissions to the resources."),
@@ -57,6 +64,8 @@ public class ResourceAccessGateFactory
 
     static final String PROP_JCR_PATH = "jcrPath";
 
+    static final String PROP_PREFIX = "checkpath.prefix";
+
     private String jcrPath;
 
     @Activate
@@ -75,6 +84,25 @@ public class ResourceAccessGateFactory
     }
 
     /**
+     * Check the permission
+     */
+    private GateResult checkPermission(final Resource resource, final String permission) {
+        if ( this.skipCheck(resource) ) {
+            return GateResult.GRANTED;
+        }
+        boolean granted = false;
+        final Session session = resource.getResourceResolver().adaptTo(Session.class);
+        if ( session != null ) {
+            try {
+                granted = session.hasPermission(jcrPath, permission);
+            } catch (final RepositoryException re) {
+                // ignore
+            }
+        }
+        return granted ? GateResult.GRANTED : GateResult.DENIED;
+    }
+
+    /**
      * @see org.apache.sling.resourceaccesssecurity.AllowingResourceAccessGate#hasReadRestrictions(org.apache.sling.api.resource.ResourceResolver)
      */
     @Override
@@ -111,19 +139,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canRead(final Resource resource) {
-        if ( this.skipCheck(resource) ) {
-            return GateResult.GRANTED;
-        }
-        final Session session = resource.getResourceResolver().adaptTo(Session.class);
-        boolean canRead = false;
-        if ( session != null ) {
-            try {
-                canRead = session.nodeExists(this.jcrPath);
-            } catch (final RepositoryException re) {
-                // ignore
-            }
-        }
-        return canRead ? GateResult.GRANTED : GateResult.DENIED;
+        return this.checkPermission(resource, Session.ACTION_READ);
     }
 
     /**
@@ -131,22 +147,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canDelete(Resource resource) {
-        if ( this.skipCheck(resource) ) {
-            return GateResult.GRANTED;
-        }
-
-        boolean canDelete = false;
-        final Session session = resource.getResourceResolver().adaptTo(Session.class);
-        if ( session != null ) {
-            try {
-                canDelete = session.hasPermission(jcrPath, Session.ACTION_REMOVE);
-            } catch (final RepositoryException re) {
-                // ignore
-            }
-        }
-
-        return canDelete ? GateResult.GRANTED : GateResult.DENIED;
-
+        return this.checkPermission(resource, Session.ACTION_REMOVE);
     }
 
     /**
@@ -154,22 +155,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canUpdate(Resource resource) {
-        if ( this.skipCheck(resource) ) {
-            return GateResult.GRANTED;
-        }
-
-        boolean canUpdate = false;
-
-        final Session session = resource.getResourceResolver().adaptTo(Session.class);
-        if ( session != null ) {
-            try {
-                canUpdate = session.hasPermission(jcrPath, Session.ACTION_SET_PROPERTY);
-            } catch (final RepositoryException re) {
-                // ignore
-            }
-        }
-
-        return canUpdate ? GateResult.GRANTED : GateResult.DENIED;
+        return this.checkPermission(resource, Session.ACTION_SET_PROPERTY);
     }
 
     /**

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 03/16: Use released Sling API

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 10e45a8ac7d18f5b224df8a706d664aab3dba2e9
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 24 22:41:02 2014 +0000

    Use released Sling API
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1561219 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 106280a..ace06fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,7 +92,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.4.3-SNAPSHOT</version>
+            <version>2.5.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-resourcesecurity] 07/16: Simplify code, use common method for permission check

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 27da478a2b02e8f42439e1a40325210984e12e79
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Mar 28 16:51:17 2014 +0000

    Simplify code, use common method for permission check
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1582821 13f79535-47bb-0310-9956-ffa450edef68
---
 .../impl/ResourceAccessGateFactory.java            | 39 +++++-----------------
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
index 7c13fed..6d9c5e2 100644
--- a/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
+++ b/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
@@ -20,7 +20,6 @@ package org.apache.sling.jcr.resourcesecurity.impl;
 
 import java.util.Map;
 
-import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -74,24 +73,13 @@ public class ResourceAccessGateFactory
     }
 
     /**
-     * Skip the check if the resource is backed by a JCR resource.
-     * This is a sanity check which should usually not be required if the system
-     * is configured correctly.
-     */
-    private boolean skipCheck(final Resource resource) {
-        // if resource is backed by a JCR node, skip check
-        return resource.adaptTo(Node.class) != null;
-    }
-
-    /**
      * Check the permission
      */
-    private GateResult checkPermission(final Resource resource, final String permission) {
-        if ( this.skipCheck(resource) ) {
-            return GateResult.GRANTED;
-        }
+    private GateResult checkPermission(final ResourceResolver resolver,
+            final String path,
+            final String permission) {
         boolean granted = false;
-        final Session session = resource.getResourceResolver().adaptTo(Session.class);
+        final Session session = resolver.adaptTo(Session.class);
         if ( session != null ) {
             try {
                 granted = session.hasPermission(jcrPath, permission);
@@ -139,7 +127,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canRead(final Resource resource) {
-        return this.checkPermission(resource, Session.ACTION_READ);
+        return this.checkPermission(resource.getResourceResolver(), resource.getPath(), Session.ACTION_READ);
     }
 
     /**
@@ -147,7 +135,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canDelete(Resource resource) {
-        return this.checkPermission(resource, Session.ACTION_REMOVE);
+        return this.checkPermission(resource.getResourceResolver(), resource.getPath(), Session.ACTION_REMOVE);
     }
 
     /**
@@ -155,7 +143,7 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canUpdate(Resource resource) {
-        return this.checkPermission(resource, Session.ACTION_SET_PROPERTY);
+        return this.checkPermission(resource.getResourceResolver(), resource.getPath(), Session.ACTION_SET_PROPERTY);
     }
 
     /**
@@ -163,17 +151,6 @@ public class ResourceAccessGateFactory
      */
     @Override
     public GateResult canCreate(String absPathName, ResourceResolver resourceResolver) {
-        boolean canCreate = false;
-
-        final Session session = resourceResolver.adaptTo(Session.class);
-        if ( session != null ) {
-            try {
-                canCreate = session.hasPermission(jcrPath, Session.ACTION_ADD_NODE);
-            } catch (final RepositoryException re) {
-                // ignore
-            }
-        }
-
-        return canCreate ? GateResult.GRANTED : GateResult.DENIED;
+        return this.checkPermission(resourceResolver, absPathName, Session.ACTION_ADD_NODE);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-jcr-resourcesecurity] 12/16: Use released resourceacesssecurity

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.resourcesecurity-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit bc2195dca35fd39604d1d032b32574b98f2aca5d
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 5 15:48:19 2015 +0000

    Use released resourceacesssecurity
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1649555 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 145783c..1bf4504 100644
--- a/pom.xml
+++ b/pom.xml
@@ -98,7 +98,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.resourceaccesssecurity</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
+            <version>1.0.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>.