sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
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 GMT
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<ServiceReference> 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



Mime
View raw message