incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r950106 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/resource/ commons/auth/src/main/java/org/apache/sling/commons/auth/impl/ jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ jcr/resource/src/test/java...
Date Tue, 01 Jun 2010 15:13:13 GMT
Author: justin
Date: Tue Jun  1 15:13:10 2010
New Revision: 950106

URL: http://svn.apache.org/viewvc?rev=950106&view=rev
Log:
SLING-1541 - adding getUserID() method to ResourceResolver

Modified:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
    sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java

Modified: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=950106&r1=950105&r2=950106&view=diff
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
(original)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java
Tue Jun  1 15:13:10 2010
@@ -357,4 +357,14 @@ public interface ResourceResolver extend
      * @since 2.1
      */
     void close();
+
+
+    /**
+     * Get the user ID, if any, associated with this resource resolver.
+     * The meaning of this identifier is an implementation detail defined
+     * by the underlying repository. This method may return null.
+     *
+     * @return the user ID
+     */
+    String getUserID();
 }

Modified: sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java?rev=950106&r1=950105&r2=950106&view=diff
==============================================================================
--- sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
(original)
+++ sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
Tue Jun  1 15:13:10 2010
@@ -820,14 +820,13 @@ public class SlingAuthenticator implemen
      */
     private void setAttributes(final ResourceResolver resolver, final String authType,
             final HttpServletRequest request) {
-        Session session = resolver.adaptTo(Session.class);
 
         final SlingAuthenticatorResourceResolver sar = new SlingAuthenticatorResourceResolver(
             resolver);
 
         // HttpService API required attributes
         // TODO - figure out if this can be change to use authInfo instead of the session
-        request.setAttribute(HttpContext.REMOTE_USER, session.getUserID());
+        request.setAttribute(HttpContext.REMOTE_USER, resolver.getUserID());
         request.setAttribute(HttpContext.AUTHENTICATION_TYPE, authType);
 
         // resource resolver for down-stream use
@@ -835,11 +834,12 @@ public class SlingAuthenticator implemen
         request.setAttribute(SlingAuthenticatorResourceResolver.ATTR_NAME, sar);
 
         // JCR session for backwards compatibility
+        Session session = resolver.adaptTo(Session.class);
         request.setAttribute(REQUEST_ATTRIBUTE_SESSION, session);
 
         log.debug(
             "setAttributes: ResourceResolver stored as request attribute: user={}, workspace={}",
-            session.getUserID(), session.getWorkspace().getName());
+            resolver.getUserID(), session.getWorkspace().getName());
     }
 
     /**

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=950106&r1=950105&r2=950106&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Tue Jun  1 15:13:10 2010
@@ -688,6 +688,13 @@ public class JcrResourceResolver
         }
     }
 
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolver#getUserID(java.lang.String)
+     */
+    public String getUserID() {
+        return getSession().getUserID();
+    }
+
     // ---------- Adaptable interface
 
     /**

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java?rev=950106&r1=950105&r2=950106&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/ResourceProviderEntryTest.java
Tue Jun  1 15:13:10 2010
@@ -258,6 +258,10 @@ public class ResourceProviderEntryTest e
         public void close() {
             // nothing to do
         }
+
+        public String getUserID() {
+            return null;
+        }
     }
 
     private static class TestResource implements Resource {

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java?rev=950106&r1=950105&r2=950106&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
Tue Jun  1 15:13:10 2010
@@ -104,4 +104,8 @@ public class MockResourceResolver implem
     public void close() {
         // nothing to do
     }
+
+    public String getUserID() {
+        return session.getUserID();
+    }
 }



Mime
View raw message