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 <[email protected]>
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
"[email protected]" <[email protected]>.

Reply via email to