Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@minotaur.apache.org Received: (qmail 73759 invoked from network); 25 Jun 2009 07:49:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jun 2009 07:49:11 -0000 Received: (qmail 74010 invoked by uid 500); 25 Jun 2009 07:49:22 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 73967 invoked by uid 500); 25 Jun 2009 07:49:22 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 73958 invoked by uid 99); 25 Jun 2009 07:49:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jun 2009 07:49:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jun 2009 07:49:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7E03123888CB; Thu, 25 Jun 2009 07:48:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r788282 - in /sling/trunk/bundles/servlets/resolver/src/main: java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java resources/OSGI-INF/metatype/metatype.properties Date: Thu, 25 Jun 2009 07:48:57 -0000 To: sling-commits@incubator.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090625074857.7E03123888CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Thu Jun 25 07:48:56 2009 New Revision: 788282 URL: http://svn.apache.org/viewvc?rev=788282&view=rev Log: SLING-1022 : Provide configuration property to specify special script user. Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java sling/trunk/bundles/servlets/resolver/src/main/resources/OSGI-INF/metatype/metatype.properties Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java?rev=788282&r1=788281&r2=788282&view=diff ============================================================================== --- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java (original) +++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java Thu Jun 25 07:48:56 2009 @@ -33,8 +33,10 @@ import java.util.List; import java.util.Map; +import javax.jcr.Credentials; import javax.jcr.RepositoryException; import javax.jcr.Session; +import javax.jcr.SimpleCredentials; import javax.servlet.Servlet; import javax.servlet.ServletContext; import javax.servlet.ServletException; @@ -54,6 +56,7 @@ import org.apache.sling.api.scripting.SlingScriptResolver; import org.apache.sling.api.servlets.OptingServlet; import org.apache.sling.api.servlets.ServletResolver; +import org.apache.sling.commons.osgi.OsgiUtil; import org.apache.sling.engine.RequestUtil; import org.apache.sling.engine.servlets.AbstractServiceReferenceConfig; import org.apache.sling.engine.servlets.ErrorHandler; @@ -101,6 +104,11 @@ */ public static final String PROP_SERVLET_ROOT = "servletresolver.servletRoot"; + /** + * @scr.property + */ + public static final String PROP_SCRIPT_USER = "servletresolver.scriptUser"; + /** The default servlet root is the first search path (which is usally /apps) */ public static final String DEFAULT_SERVLET_ROOT = "0"; @@ -549,6 +557,16 @@ } catch (RepositoryException e) { throw new SlingException("Unable to create new admin session.", e); } + // if a script user is configured we use this user to read the scripts + final String scriptUser = OsgiUtil.toString(properties.get(PROP_SCRIPT_USER), null); + if ( scriptUser != null && scriptUser.length() > 0 ) { + Credentials creds = new SimpleCredentials(scriptUser, new char[0]); + try { + this.scriptSession = this.scriptSession.impersonate(creds); + } catch (RepositoryException e) { + throw new SlingException("Unable to impersonate to script user: " + scriptUser, e); + } + } this.scriptResolver = this.resourceResolverFactory.getResourceResolver(this.scriptSession); Collection refs; Modified: sling/trunk/bundles/servlets/resolver/src/main/resources/OSGI-INF/metatype/metatype.properties URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=788282&r1=788281&r2=788282&view=diff ============================================================================== --- sling/trunk/bundles/servlets/resolver/src/main/resources/OSGI-INF/metatype/metatype.properties (original) +++ sling/trunk/bundles/servlets/resolver/src/main/resources/OSGI-INF/metatype/metatype.properties Thu Jun 25 07:48:56 2009 @@ -38,3 +38,9 @@ path. The default value is "/apps". This path should be part of the search \ path configured in the Resource Resolver Factory otherwise a thus registered \ servlet may not be found. + +servletresolver.scriptUser.name = Script User +servletresolver.scriptUser.description = This optional property can specify \ + the repository user who is used to read the scripts. If none is specified \ + the admin user is used by default. + \ No newline at end of file