sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-jcr-resourcesecurity] 03/05: SLING-4291 : NPE if optional prefix is not configured
Date Tue, 07 Nov 2017 09:49:28 GMT
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.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resourcesecurity.git

commit 41ae4aa1c25435d8043508d86181f4595d83dab4
Author: Carsten Ziegeler <cziegeler@apache.org>
AuthorDate: Fri Jan 9 12:30:20 2015 +0000

    SLING-4291 : NPE if optional prefix is not configured
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/jcr/resourcesecurity@1650513
13f79535-47bb-0310-9956-ffa450edef68
---
 .../jcr/resourcesecurity/impl/ResourceAccessGateFactory.java     | 9 +++------
 1 file changed, 3 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 4cfe4eb..a2171f7 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
@@ -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);

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

Mime
View raw message