sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1582823 - /sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
Date Fri, 28 Mar 2014 16:54:20 GMT
Author: cziegeler
Date: Fri Mar 28 16:54:19 2014
New Revision: 1582823

URL: http://svn.apache.org/r1582823
Log:
Implement deep structure check based on the resource path

Modified:
    sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java

Modified: sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java?rev=1582823&r1=1582822&r2=1582823&view=diff
==============================================================================
--- sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
(original)
+++ sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java
Fri Mar 28 16:54:19 2014
@@ -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
             }



Mime
View raw message