You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by tm...@apache.org on 2016/12/09 14:44:36 UTC

svn commit: r1773407 - in /sling/trunk: bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/ bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/ launchpad/builder/src/main/provisioning/

Author: tmaret
Date: Fri Dec  9 14:44:36 2016
New Revision: 1773407

URL: http://svn.apache.org/viewvc?rev=1773407&view=rev
Log:
SLING-5233 - Remove getAdministrativeResourceResolver() usage from org.apache.sling.i18n

* Remove support for custom user/pwd to access the repository
* Use sling-i18n service user when accessing the repository

Modified:
    sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
    sling/trunk/bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/metatype.properties
    sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt
    sling/trunk/launchpad/builder/src/main/provisioning/sling.txt

Modified: sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?rev=1773407&r1=1773406&r2=1773407&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java (original)
+++ sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java Fri Dec  9 14:44:36 2016
@@ -75,11 +75,7 @@ public class JcrResourceBundleProvider i
 
     private static final int DEFAULT_INVALIDATION_DELAY = 5000;
 
-    @Property(value = "")
-    private static final String PROP_USER = "user";
-
-    @Property(value = "")
-    private static final String PROP_PASS = "password";
+    private static final String SLING_I18N_USER = "sling-i18n";
 
     @Property(value = "en")
     private static final String PROP_DEFAULT_LOCALE = "locale.default";
@@ -111,8 +107,7 @@ public class JcrResourceBundleProvider i
 
     /**
      * The resource resolver used to access the resource bundles. This object is
-     * retrieved from the {@link #resourceResolverFactory} using the administrative
-     * session or the session acquired using the {@link #repoCredentials}.
+     * retrieved from the {@link #resourceResolverFactory} using the {@link #SLING_I18N_USER} service user session.
      */
     private ResourceResolver resourceResolver;
 
@@ -359,18 +354,6 @@ public class JcrResourceBundleProvider i
      * @throws LoginException
      */
     protected void activate(BundleContext context, Map<String, Object> props) throws LoginException {
-        Map<String, Object> repoCredentials;
-        String user = PropertiesUtil.toString(props.get(PROP_USER), null);
-        if (user == null || user.length() == 0) {
-            repoCredentials = null;
-        } else {
-            String pass = PropertiesUtil.toString(props.get(PROP_PASS), null);
-            char[] pwd = (pass == null) ? new char[0] : pass.toCharArray();
-            repoCredentials = new HashMap<String, Object>();
-            repoCredentials.put(ResourceResolverFactory.USER, user);
-            repoCredentials.put(ResourceResolverFactory.PASSWORD, pwd);
-        }
-
         String localeString = PropertiesUtil.toString(props.get(PROP_DEFAULT_LOCALE),
             null);
         this.defaultLocale = toLocale(localeString);
@@ -379,11 +362,9 @@ public class JcrResourceBundleProvider i
         this.bundleContext = context;
         invalidationDelay = PropertiesUtil.toLong(props.get(PROP_INVALIDATION_DELAY), DEFAULT_INVALIDATION_DELAY);
         if (this.resourceResolverFactory != null) { // this is only null during test execution!
-            if (repoCredentials == null) {
-                resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
-            } else {
-                resourceResolver = resourceResolverFactory.getResourceResolver(repoCredentials);
-            }
+            Map<String, Object> authInfo = Collections.<String, Object>singletonMap(
+                    ResourceResolverFactory.SUBSERVICE, SLING_I18N_USER);
+            resourceResolver = resourceResolverFactory.getServiceResourceResolver(authInfo);
             scheduleReloadBundles(false);
         }
 

Modified: sling/trunk/bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1773407&r1=1773406&r2=1773407&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ sling/trunk/bundles/extensions/i18n/src/main/resources/OSGI-INF/metatype/metatype.properties Fri Dec  9 14:44:36 2016
@@ -24,15 +24,6 @@ provider.description = ResourceBundlePro
  name and password are used to access the repository. Failing to access the \
  repository, effectively disables the provider.
 
-user.name = User Name
-user.description = The name of the user to log in to the repository to get the \
- resources. If this field is empty, the provider accesses the repository as \
- the administrative user.
-
-password.name = Password
-password.description = The password used to log in to the repository to get \
- the resources. This field is only used if the user name field is not empty.
-
 locale.default.name = Default Locale
 locale.default.description = The default locale to assume if none can be \
  resolved otherwise. This value must be in the form acceptable to the \

Modified: sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt?rev=1773407&r1=1773406&r2=1773407&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt (original)
+++ sling/trunk/launchpad/builder/src/main/provisioning/repoinit.txt Fri Dec  9 14:44:36 2016
@@ -41,6 +41,13 @@
         allow   jcr:read    on /libs/sling/xss,/apps/sling/xss
     end
 
+    # sling-i18n
+    create service user sling-i18n
+
+    set ACL for sling-i18n
+        allow   jcr:read    on /
+    end
+
     # sling-jcr-install
     create service user sling-jcr-install
 

Modified: sling/trunk/launchpad/builder/src/main/provisioning/sling.txt
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/builder/src/main/provisioning/sling.txt?rev=1773407&r1=1773406&r2=1773407&view=diff
==============================================================================
--- sling/trunk/launchpad/builder/src/main/provisioning/sling.txt (original)
+++ sling/trunk/launchpad/builder/src/main/provisioning/sling.txt Fri Dec  9 14:44:36 2016
@@ -179,6 +179,11 @@
       "org.apache.sling.xss\=sling-xss"
     ]
 
+  org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-i18n
+    user.mapping=[
+      "org.apache.sling.i18n\=sling-i18n"
+    ]
+
   org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-jcr-install
     user.mapping=[
       "org.apache.sling.installer.provider.jcr\=sling-jcr-install"