You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:34:37 UTC

[sling-org-apache-sling-featureflags] 18/25: SLING-3148 : Get resource resolver from authentication support via request attribute

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.featureflags-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-featureflags.git

commit e2fe9d0a6c7574aa0e08d7c1d06ea4b2288caa47
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jan 29 16:38:09 2014 +0000

    SLING-3148 : Get resource resolver from authentication support via request attribute
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/feature-flags@1562505 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                      |  6 ++++++
 .../apache/sling/featureflags/impl/ExecutionContextImpl.java | 12 +++++++++++-
 .../org/apache/sling/featureflags/impl/FeatureManager.java   |  7 -------
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index 75a28cd..6ea7c84 100644
--- a/pom.xml
+++ b/pom.xml
@@ -53,6 +53,12 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.auth.core</artifactId>
+            <version>1.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
         </dependency>
diff --git a/src/main/java/org/apache/sling/featureflags/impl/ExecutionContextImpl.java b/src/main/java/org/apache/sling/featureflags/impl/ExecutionContextImpl.java
index cfd673a..82f82da 100644
--- a/src/main/java/org/apache/sling/featureflags/impl/ExecutionContextImpl.java
+++ b/src/main/java/org/apache/sling/featureflags/impl/ExecutionContextImpl.java
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.auth.core.AuthenticationSupport;
 import org.apache.sling.featureflags.ExecutionContext;
 
 /**
@@ -40,9 +41,18 @@ public class ExecutionContextImpl implements ExecutionContext {
 
     public ExecutionContextImpl(final HttpServletRequest request) {
         this.request = request;
-        this.resourceResolver = (request instanceof SlingHttpServletRequest)
+        ResourceResolver resolver = (request instanceof SlingHttpServletRequest)
                 ? ((SlingHttpServletRequest) request).getResourceResolver()
                 : null;
+        if ( resolver == null ) {
+            // get ResourceResolver (set by AuthenticationSupport)
+            final Object resolverObject = request.getAttribute(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER);
+            resolver = (resolverObject instanceof ResourceResolver)
+                    ? (ResourceResolver) resolverObject
+                    : null;
+
+        }
+        this.resourceResolver = resolver;
     }
 
     @Override
diff --git a/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java b/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
index fd87123..b5297a8 100644
--- a/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
+++ b/src/main/java/org/apache/sling/featureflags/impl/FeatureManager.java
@@ -105,13 +105,6 @@ public class FeatureManager {
                     put("service.ranking", Integer.MIN_VALUE);
                 }
             }));
-        services.add(bundleContext.registerService(Filter.class.getName(), new CurrentClientContextFilter(this),
-            new Hashtable<String, Object>() {
-            {
-                put("sling.filter.scope", "REQUEST");
-                put("service.ranking", Integer.MIN_VALUE);
-            }
-        }));
         this.services = services;
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.