sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1779444 - in /sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution: agent/impl/ util/impl/
Date Thu, 19 Jan 2017 10:24:18 GMT
Author: tommaso
Date: Thu Jan 19 10:24:17 2017
New Revision: 1779444

URL: http://svn.apache.org/viewvc?rev=1779444&view=rev
Log:
SLING-6477 - use service user when impersonating API is not available

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/util/impl/DistributionUtils.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java?rev=1779444&r1=1779443&r2=1779444&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/ForwardDistributionAgentFactory.java
Thu Jan 19 10:24:17 2017
@@ -97,7 +97,8 @@ public class ForwardDistributionAgentFac
     @Property(boolValue = true, label = "Enabled", description = "Whether or not to start
the distribution agent.")
     private static final String ENABLED = "enabled";
 
-    @Property(label = "Service Name", description = "The name of the service used to access
the repository.")
+    @Property(label = "Service Name", description = "The name of the service used to access
the repository. " +
+            "If not set, the calling user ResourceResolver will be used")
     private static final String SERVICE_NAME = "serviceName";
 
     @Property(options = {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java?rev=1779444&r1=1779443&r2=1779444&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/QueueDistributionAgentFactory.java
Thu Jan 19 10:24:17 2017
@@ -88,7 +88,8 @@ public class QueueDistributionAgentFacto
     private static final String ENABLED = "enabled";
 
 
-    @Property(label = "Service Name", description = "The name of the service used to access
the repository.")
+    @Property(label = "Service Name", description = "The name of the service used to access
the repository. " +
+            "If not set, the calling user ResourceResolver will be used")
     private static final String SERVICE_NAME = "serviceName";
 
     @Property(options = {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java?rev=1779444&r1=1779443&r2=1779444&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SimpleDistributionAgent.java
Thu Jan 19 10:24:17 2017
@@ -59,7 +59,7 @@ import org.apache.sling.jcr.api.SlingRep
  * Basic implementation of a {@link org.apache.sling.distribution.agent.DistributionAgent}
  */
 public class SimpleDistributionAgent implements DistributionAgent {
-    private final static String DEFAULT_AGENT_SERVICE = "defaultAgentService";
+    public final static String DEFAULT_AGENT_SERVICE = "defaultAgentService";
 
     private final DistributionQueueProvider queueProvider;
     private final DistributionPackageImporter distributionPackageImporter;

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java?rev=1779444&r1=1779443&r2=1779444&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/agent/impl/SyncDistributionAgentFactory.java
Thu Jan 19 10:24:17 2017
@@ -93,7 +93,8 @@ public class SyncDistributionAgentFactor
     private static final String ENABLED = "enabled";
 
 
-    @Property(label = "Service Name", description = "The name of the service used to access
the repository.")
+    @Property(label = "Service Name", description = "The name of the service used to access
the repository. " +
+            "If not set, the calling user ResourceResolver will be used")
     private static final String SERVICE_NAME = "serviceName";
 
     @Property(options = {

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/util/impl/DistributionUtils.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/util/impl/DistributionUtils.java?rev=1779444&r1=1779443&r2=1779444&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/util/impl/DistributionUtils.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/util/impl/DistributionUtils.java
Thu Jan 19 10:24:17 2017
@@ -85,13 +85,18 @@ public class DistributionUtils {
             Map<String, Object> authenticationInfo = new HashMap<String, Object>();
 
             if (subServiceName == null && user != null) {
-                Session session = slingRepository.impersonateFromService(service, new SimpleCredentials(user,
new char[0]), null);
-                authenticationInfo.put(AUTHENTICATION_INFO_SESSION, session);
-                resourceResolver = resourceResolverFactory.getResourceResolver(authenticationInfo);
+                try {
+                    Session session = slingRepository.impersonateFromService(service, new
SimpleCredentials(user, new char[0]), null);
+                    authenticationInfo.put(AUTHENTICATION_INFO_SESSION, session);
+                } catch (NoSuchMethodError nsme) {
+                    log.warn("without sling.jcr.api 2.3.0 content will be aggregated using
service {}", service);
+                    Session session = slingRepository.loginService(service, null);
+                    authenticationInfo.put(AUTHENTICATION_INFO_SESSION, session);
+                }
             } else {
                 authenticationInfo.put(ResourceResolverFactory.SUBSERVICE, subServiceName);
-                resourceResolver = resourceResolverFactory.getServiceResourceResolver(authenticationInfo);
             }
+            resourceResolver = resourceResolverFactory.getServiceResourceResolver(authenticationInfo);
 
             return resourceResolver;
         } catch (LoginException le) {



Mime
View raw message