Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 622D8C624 for ; Fri, 9 Jan 2015 12:30:20 +0000 (UTC) Received: (qmail 58127 invoked by uid 500); 9 Jan 2015 12:30:21 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 58066 invoked by uid 500); 9 Jan 2015 12:30:21 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 58056 invoked by uid 99); 9 Jan 2015 12:30:21 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jan 2015 12:30:21 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 45E4CAC010E; Fri, 9 Jan 2015 12:30:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1650513 - /sling/trunk/contrib/jcr/resourcesecurity/src/main/java/org/apache/sling/jcr/resourcesecurity/impl/ResourceAccessGateFactory.java Date: Fri, 09 Jan 2015 12:30:20 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150109123021.45E4CAC010E@hades.apache.org> 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 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);