You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2015/01/09 13:30:20 UTC

svn commit: r1650513 - /sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java

Author: cziegeler
Date: Fri Jan  9 12:30:20 2015
New Revision: 1650513

URL: http://svn.apache.org/r1650513
Log:
SLING-4291 : NPE if optional prefix is not configured

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=1650513&r1=1650512&r2=1650513&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 Jan  9 12:30:20 2015
@@ -73,11 +73,8 @@ public class ResourceAccessGateFactory
     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 != null ) {
-            if ( !this.prefix.endsWith("/") ) {
-                this.prefix = this.prefix + "/";
-            }
-            this.jcrPath = this.jcrPath + "/";
+        if ( this.prefix != null && !this.prefix.endsWith("/") ) {
+             this.prefix = this.prefix + "/";
         }
     }
 
@@ -92,7 +89,7 @@ public class ResourceAccessGateFactory
         if ( session != null ) {
             String checkPath = this.jcrPath;
             if ( this.prefix != null && path.startsWith(this.prefix) ) {
-                checkPath = this.jcrPath + path.substring(this.prefix.length());
+                checkPath = this.jcrPath + path.substring(this.prefix.length() - 1);
             }
             try {
                 granted = session.hasPermission(checkPath, permission);