incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1499653 - in /sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver: ./ src/main/java/org/apache/sling/resourceresolver/impl/ src/main/java/org/apache/sling/resourceresolver/impl/console/ src/main/java/org/apache/sling/...
Date Thu, 04 Jul 2013 04:41:34 GMT
Author: fmeschbe
Date: Thu Jul  4 04:41:34 2013
New Revision: 1499653

URL: http://svn.apache.org/r1499653
Log:
Implement support for service based ResourceResolver and Session access

- Update with latest changes from trunk

Added:
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java
      - copied, changed from r1499651, sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java
Modified:
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/   (props changed)
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/pom.xml
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
  (contents, props changed)
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderList.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderFactoryHandler.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderHandler.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
    sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderListTest.java

Propchange: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/
------------------------------------------------------------------------------
    svn:mergeinfo = /sling/trunk/bundles/resourceresolver:1458683-1499651

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/pom.xml?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/pom.xml (original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/pom.xml Thu
Jul  4 04:41:34 2013
@@ -22,12 +22,12 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>15</version>
+        <version>16</version>
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
     <artifactId>org.apache.sling.resourceresolver</artifactId>
-    <version>1.0.5-SNAPSHOT</version>
+    <version>1.0.7-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Resource Resolver</name>
@@ -115,7 +115,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.3.1-SNAPSHOT</version>
+            <version>2.4.3-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -130,7 +130,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.2.1-SNAPSHOT</version>
+            <version>2.2.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverFactoryImpl.java
Thu Jul  4 04:41:34 2013
@@ -26,6 +26,7 @@ import org.apache.sling.api.resource.Log
 import org.apache.sling.api.resource.ResourceProviderFactory;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.security.ResourceAccessSecurity;
 import org.apache.sling.resourceresolver.impl.console.ResourceResolverWebConsolePlugin;
 import org.apache.sling.resourceresolver.impl.helper.ResourceDecoratorTracker;
 import org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext;
@@ -36,6 +37,7 @@ import org.apache.sling.resourceresolver
 import org.apache.sling.serviceusermapping.ServiceUserMapper;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,6 +61,8 @@ public class ResourceResolverFactoryImpl
 
     /** The activator */
     private final ResourceResolverFactoryActivator activator;
+    
+    private ServiceTracker resourceAccessSecurityTracker;
 
     private final ServiceUserMapper serviceUserMapper;
 
@@ -139,7 +143,7 @@ public class ResourceResolverFactoryImpl
                     final boolean isAdmin)
     throws LoginException {
         // create context
-        final ResourceResolverContext ctx = new ResourceResolverContext(isAdmin, authenticationInfo);
+        final ResourceResolverContext ctx = new ResourceResolverContext(isAdmin, authenticationInfo,
resourceAccessSecurityTracker);
 
         // login
         this.activator.getRootProviderEntry().loginToRequiredFactories(ctx);
@@ -167,6 +171,10 @@ public class ResourceResolverFactoryImpl
         } catch (final Exception e) {
             logger.error("activate: Cannot access repository, failed setting up Mapping Support",
e);
         }
+        
+        // create and open service tracker for ResourceAccessSecurity
+        resourceAccessSecurityTracker = new ServiceTracker(bundleContext, ResourceAccessSecurity.class.getName(),
null);
+        resourceAccessSecurityTracker.open();
     }
 
     /**
@@ -182,6 +190,8 @@ public class ResourceResolverFactoryImpl
             mapEntries.dispose();
             mapEntries = MapEntries.EMPTY;
         }
+
+        resourceAccessSecurityTracker.close();
     }
 
     public ResourceDecoratorTracker getResourceDecoratorTracker() {
@@ -215,4 +225,12 @@ public class ResourceResolverFactoryImpl
     public int getDefaultVanityPathRedirectStatus() {
         return this.activator.getDefaultVanityPathRedirectStatus();
     }
+    
+    /**
+     * get's the ServiceTracker of the ResourceAccessSecurity service
+     */
+    
+    public ServiceTracker getResourceAccessSecurityTracker () {
+        return resourceAccessSecurityTracker;
+    }
 }
\ No newline at end of file

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
Thu Jul  4 04:41:34 2013
@@ -123,7 +123,8 @@ public class ResourceResolverImpl extend
         }
 
         // create new context
-        final ResourceResolverContext newContext = new ResourceResolverContext(this.context.isAdmin(),
newAuthenticationInfo);
+        final ResourceResolverContext newContext = new ResourceResolverContext(this.context.isAdmin(),

+                newAuthenticationInfo, factory.getResourceAccessSecurityTracker() );
         this.factory.getRootProviderEntry().loginToRequiredFactories(newContext);
 
         // create a regular resource resolver
@@ -869,7 +870,7 @@ public class ResourceResolverImpl extend
         } else {
             path = parent.getPath() + '/' + childName;
         }
-        Resource child = getResourceInternal(path);
+        Resource child = getResourceInternal( ResourceUtil.normalize(path) );
         if (child != null) {
             final String alias = getProperty(child, PROP_REDIRECT_INTERNAL);
             if (alias != null) {
@@ -895,7 +896,7 @@ public class ResourceResolverImpl extend
                 } else {
                     aliasPath = parent.getPath() + '/' + aliasName;
                 }
-                final Resource aliasedChild = getResourceInternal(aliasPath);
+                final Resource aliasedChild = getResourceInternal( ResourceUtil.normalize(aliasPath)
);
                 logger.debug("getChildInternal: Found Resource {} with alias {} to use",
aliasedChild, childName);
                 return aliasedChild;
             }
@@ -966,7 +967,7 @@ public class ResourceResolverImpl extend
     }
 
     private String mangleNamespaces(String absPath) {
-        if (factory.isMangleNamespacePrefixes() && absPath.contains(MANGLE_NAMESPACE_OUT_SUFFIX))
{
+        if (factory.isMangleNamespacePrefixes() && absPath != null && absPath.contains(MANGLE_NAMESPACE_OUT_SUFFIX))
{
             final Pattern p = Pattern.compile(MANGLE_NAMESPACE_OUT);
             final Matcher m = p.matcher(absPath);
 
@@ -1164,4 +1165,11 @@ public class ResourceResolverImpl extend
         }
         return result;
     }
+
+    /**
+     * @see org.apache.sling.api.resource.ResourceResolver#refresh()
+     */
+    public void refresh() {
+        this.context.refresh();
+    }
 }

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
Thu Jul  4 04:41:34 2013
@@ -70,7 +70,8 @@ public class ResourceResolverWebConsoleP
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put(Constants.SERVICE_PID, getClass().getName());
         props.put("felix.webconsole.label", "jcrresolver");
-        props.put("felix.webconsole.title", "Sling Resource Resolver");
+        props.put("felix.webconsole.title", "Resource Resolver");
+        props.put("felix.webconsole.category", "Sling");
         props.put("felix.webconsole.configprinter.modes", "always");
 
         service = context.registerService(

Propchange: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/console/ResourceResolverWebConsolePlugin.java
            ('svn:mergeinfo' removed)

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/ResourceResolverContext.java
Thu Jul  4 04:41:34 2013
@@ -25,8 +25,10 @@ import java.util.Set;
 import org.apache.sling.api.resource.DynamicResourceProvider;
 import org.apache.sling.api.resource.ModifyingResourceProvider;
 import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.RefreshableResourceProvider;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * This class keeps track of the used resource providers for a
@@ -41,6 +43,9 @@ public class ResourceResolverContext {
     /** A set of all dynamic providers (for closing them later on) */
     private final Set<DynamicResourceProvider> dynamicProviders = new HashSet<DynamicResourceProvider>();
 
+    /** A set of all refreshable providers */
+    private final Set<RefreshableResourceProvider> refreshableProviders = new HashSet<RefreshableResourceProvider>();
+
     /** A set of all modifying providers */
     private final Set<ModifyingResourceProvider> modifyingProviders = new HashSet<ModifyingResourceProvider>();
 
@@ -51,13 +56,17 @@ public class ResourceResolverContext {
      * The original authentication information - this is used for cloning and lazy logins.
      */
     private final Map<String, Object> originalAuthInfo;
+    
+    /** service tracker for ResourceAccessSecurity service */
+    private final ServiceTracker resourceAccessSecurityTracker;
 
     /**
      * Create a new resource resolver context.
      */
-    public ResourceResolverContext(final boolean isAdmin, final Map<String, Object>
originalAuthInfo) {
+    public ResourceResolverContext(final boolean isAdmin, final Map<String, Object>
originalAuthInfo, final ServiceTracker resourceAccessSecurityTracker) {
         this.isAdmin = isAdmin;
         this.originalAuthInfo = originalAuthInfo;
+        this.resourceAccessSecurityTracker = resourceAccessSecurityTracker;
     }
 
     /**
@@ -87,6 +96,9 @@ public class ResourceResolverContext {
         if (provider instanceof ModifyingResourceProvider) {
             this.modifyingProviders.add((ModifyingResourceProvider) provider);
         }
+        if (provider instanceof RefreshableResourceProvider) {
+            this.refreshableProviders.add((RefreshableResourceProvider)provider);
+        }
     }
 
     /**
@@ -121,6 +133,7 @@ public class ResourceResolverContext {
         }
         this.dynamicProviders.clear();
         this.providers.clear();
+        this.refreshableProviders.clear();
     }
 
     /**
@@ -152,4 +165,21 @@ public class ResourceResolverContext {
         }
         return false;
     }
+
+    /**
+     * Refresh
+     */
+    public void refresh() {
+        for(final RefreshableResourceProvider provider : this.refreshableProviders) {
+            provider.refresh();
+        }
+    }
+    
+    /**
+     * get's the ServiceTracker of the ResourceAccessSecurity service
+     */
+    public ServiceTracker getResourceAccessSecurityTracker () {
+        return resourceAccessSecurityTracker;
+    }
+    
 }

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderList.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderList.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderList.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderList.java
Thu Jul  4 04:41:34 2013
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 
+import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.resourceresolver.impl.tree.ProviderHandler;
 import org.apache.sling.resourceresolver.impl.tree.ResourceProviderFactoryHandler;
 import org.apache.sling.resourceresolver.impl.tree.ResourceProviderHandler;
@@ -183,6 +184,25 @@ public class SortedProviderList<T> {
     public void remove(final ResourceProviderFactoryHandler factory) {
         this.removeFromList(factory);
     }
+    
+    /**
+     * returns the ProviderHandler for a specific resource provider
+     */
+    public ProviderHandler getProviderHandler ( ResourceResolverContext ctx, ResourceProvider
resourceProvider )
+    {
+        ProviderHandler returnValue = null;
+        final List<Entry> list = new ArrayList<Entry>();
+        list.addAll(Arrays.asList(this.sortedList));
+        final Iterator<Entry> i = list.iterator();
+        while ( i.hasNext() ) {
+            final Entry entry = i.next();
+            if ( entry.handler.getResourceProvider(ctx).equals(resourceProvider) ) {
+                returnValue = entry.handler;
+                break;
+            }
+        }
+        return returnValue;
+    }
 
     private static final class Entry implements Comparable<Entry> {
 

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntry.java
Thu Jul  4 04:41:34 2013
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.resourceresolver.impl.ResourceResolverImpl;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -38,6 +39,9 @@ import org.slf4j.LoggerFactory;
  */
 public class MapEntry implements Comparable<MapEntry> {
 
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+	
     private static final Pattern[] URL_WITH_PORT_MATCH = {
         Pattern.compile("http/([^/]+)(\\.[^\\d/]+)(/.*)?$"),
         Pattern.compile("https/([^/]+)(\\.[^\\d/]+)(/.*)?$") };
@@ -265,7 +269,11 @@ public class MapEntry implements Compara
             final String[] redirects = getRedirect();
             final String[] results = new String[redirects.length];
             for (int i = 0; i < redirects.length; i++) {
-                results[i] = m.replaceFirst(redirects[i]);
+            	try{
+            		 results[i] = m.replaceFirst(redirects[i]);
+            	}catch(StringIndexOutOfBoundsException siob){
+            		log.debug("Exception while replacing, ignoring entry {} ",redirects[i],siob);
+             	}               
             }
             return results;
         }

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ProviderHandler.java
Thu Jul  4 04:41:34 2013
@@ -29,9 +29,11 @@ import org.apache.sling.api.resource.Que
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.security.ResourceAccessSecurity;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext;
 import org.osgi.framework.Constants;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * The provider handler is the common base class for the
@@ -54,6 +56,9 @@ public abstract class ProviderHandler im
 
     /** Owns roots? */
     private final boolean ownsRoots;
+    
+    /** use ResourceAccessSecurity? */
+    private final boolean useResourceAccessSecurity;
 
     /**
      * Create a new handler
@@ -85,6 +90,7 @@ public abstract class ProviderHandler im
             this.roots = configuredRoots.toArray(new String[configuredRoots.size()]);
         }
         this.ownsRoots = PropertiesUtil.toBoolean(properties.get(ResourceProvider.OWNS_ROOTS),
false);
+        this.useResourceAccessSecurity = PropertiesUtil.toBoolean(properties.get(ResourceProvider.USE_RESOURCE_ACCESS_SECURITY),
false);
         final Set<String> configuredLanguages = new HashSet<String>();
         final String[] languages = PropertiesUtil.toStringArray(properties.get(QueriableResourceProvider.LANGUAGES));
         if ( languages != null) {
@@ -103,6 +109,54 @@ public abstract class ProviderHandler im
             this.queryLanguages = configuredLanguages;
         }
     }
+    
+    /**
+     * applies resource access security if configured
+     */
+    protected Resource getReadableResource ( final ResourceResolverContext ctx, Resource
resource ) {
+        Resource returnValue = null;
+        
+        if (useResourceAccessSecurity && resource != null) {
+            ServiceTracker serviceTracker = ctx
+                    .getResourceAccessSecurityTracker();
+            if (serviceTracker != null) {
+                ResourceAccessSecurity resourceAccessSecurity = (ResourceAccessSecurity)
serviceTracker
+                        .getService();
+                if (resourceAccessSecurity != null) {
+                    returnValue = resourceAccessSecurity
+                            .getReadableResource(resource);
+                }
+            }
+        } else {
+            returnValue = resource;
+        }
+            
+        return returnValue;
+    }
+    
+    /**
+     * applies resource access security if configured
+     */
+    protected Iterator<Resource> getReadableChildrenIterator ( final ResourceResolverContext
ctx, Iterator<Resource> childrenIterator ) {
+        Iterator<Resource> returnValue = null;
+        if ( useResourceAccessSecurity && childrenIterator != null ) {
+            List<Resource> childs = new ArrayList<Resource>();
+            while ( childrenIterator.hasNext() )
+            {
+                Resource res = getReadableResource( ctx, childrenIterator.next() );
+                if ( res != null )
+                {
+                    childs.add(res);
+                }
+            }
+            returnValue = childs.iterator();
+        }
+        else {
+            returnValue = childrenIterator;
+        }
+            
+        return returnValue;
+    }
 
     /**
      * Return the service properties.

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderFactoryHandler.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderFactoryHandler.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderFactoryHandler.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderFactoryHandler.java
Thu Jul  4 04:41:34 2013
@@ -104,7 +104,7 @@ public class ResourceProviderFactoryHand
     public Resource getResource(final ResourceResolverContext ctx, final ResourceResolver
resourceResolver, final String path) {
         final ResourceProvider rp = this.getResourceProvider(ctx);
         if ( rp != null ) {
-            return rp.getResource(resourceResolver, path);
+            return getReadableResource(ctx, rp.getResource(resourceResolver, path) );
         }
         return null;
     }
@@ -115,7 +115,7 @@ public class ResourceProviderFactoryHand
     public Iterator<Resource> listChildren(final ResourceResolverContext ctx, final
Resource parent) {
         final ResourceProvider rp = this.getResourceProvider(ctx);
         if ( rp != null ) {
-            return rp.listChildren(parent);
+            return getReadableChildrenIterator( ctx, rp.listChildren(parent) );
         }
         return null;
     }

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderHandler.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderHandler.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderHandler.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/ResourceProviderHandler.java
Thu Jul  4 04:41:34 2013
@@ -47,14 +47,14 @@ public class ResourceProviderHandler ext
      * @see ResourceProvider#getResource(ResourceResolver, String)
      */
     public Resource getResource(final ResourceResolverContext ctx, final ResourceResolver
resourceResolver, final String path) {
-        return this.resourceProvider.getResource(resourceResolver, path);
+        return getReadableResource(ctx, this.resourceProvider.getResource(resourceResolver,
path) );
     }
 
     /**
      * @see ResourceProvider#listChildren(Resource)
      */
     public Iterator<Resource> listChildren(final ResourceResolverContext ctx, final
Resource parent) {
-        return this.resourceProvider.listChildren(parent);
+        return getReadableChildrenIterator( ctx, this.resourceProvider.listChildren(parent)
);
     }
 
     /**

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/tree/RootResourceProviderEntry.java
Thu Jul  4 04:41:34 2013
@@ -134,7 +134,9 @@ public class RootResourceProviderEntry e
             private Resource nextObject = this.seek();
 
             private Iterator<Resource> nextResourceIter;
-
+            
+            private ProviderHandler actProviderHandler;
+            
             private Resource seek() {
                 Resource result = null;
                 if ( nextResourceIter == null || !nextResourceIter.hasNext() ) {
@@ -142,12 +144,16 @@ public class RootResourceProviderEntry e
                     while ( i.hasNext() && nextResourceIter == null ) {
                         final QueriableResourceProvider adap = i.next();
                         nextResourceIter = adap.findResources(resolver, query, language);
+                        actProviderHandler = queriableProviders.getProviderHandler(ctx, adap);
                     }
                 }
                 if ( nextResourceIter != null ) {
                     while ( nextResourceIter.hasNext() && result == null ) {
                         result = nextResourceIter.next();
                     }
+                    if ( actProviderHandler != null ) {
+                        result = actProviderHandler.getReadableResource(ctx, result);
+                    }
                     if ( result == null ) {
                         result = seek();
                     }

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/MockedResourceResolverImplTest.java
Thu Jul  4 04:41:34 2013
@@ -340,7 +340,7 @@ public class MockedResourceResolverImplT
         Dictionary<String, Object> properties = new Hashtable<String, Object>();
         properties.put("resource.resolver.virtual", new String[] { "/:/" });
         properties.put("resource.resolver.mapping", new String[] { "/:/",
-            "/content/:/", "/system/docroot/:/" });
+            "/content/:/", "/system/docroot/:/", "/content.html-/$" });
         properties.put("resource.resolver.allowDirect", true);
         properties.put("resource.resolver.searchpath", new String[] { "/apps",
             "/libs" });
@@ -478,6 +478,10 @@ public class MockedResourceResolverImplT
         // test path mapping without a request.
         path = resourceResolver.map("/factory/test");
         Assert.assertEquals("/factory/test", path);
+        
+        buildResource("/content", EMPTY_RESOURCE_LIST, resourceResolver, factoryResourceProvider);
+        path = resourceResolver.map("/content.html");
+        Assert.assertEquals("/content.html", path);
 
     }
 

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverImplTest.java
Thu Jul  4 04:41:34 2013
@@ -54,11 +54,11 @@ public class ResourceResolverImplTest {
 
     @Before public void setup() {
         resFac = new ResourceResolverFactoryImpl(new ResourceResolverFactoryActivator(),
/* TODO: using Bundle */ null, null);
-        resResolver = new ResourceResolverImpl(resFac, new ResourceResolverContext(false,
null));
+        resResolver = new ResourceResolverImpl(resFac, new ResourceResolverContext(false,
null, null));
     }
 
     @Test public void testClose() throws Exception {
-        final ResourceResolver rr = new ResourceResolverImpl(resFac, new ResourceResolverContext(false,
null));
+        final ResourceResolver rr = new ResourceResolverImpl(resFac, new ResourceResolverContext(false,
null, null));
         assertTrue(rr.isLive());
         rr.close();
         assertFalse(rr.isLive());
@@ -355,7 +355,7 @@ public class ResourceResolverImplTest {
                     }
 
                 },
-                new ResourceResolverContext(false, null));
+                new ResourceResolverContext(false, null, null));
         resolvers.add(resolver);
 
         // the resources to test
@@ -391,7 +391,7 @@ public class ResourceResolverImplTest {
                     }
 
                 },
-                new ResourceResolverContext(false, null));
+                new ResourceResolverContext(false, null, null));
         resolvers.add(resolver);
         final Resource r = new SyntheticResource(resolver, "/a", "a:b") {
             @Override

Copied: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java
(from r1499651, sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java)
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java?p2=sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java&p1=sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java&r1=1499651&r2=1499653&rev=1499653&view=diff
==============================================================================
--- sling/trunk/bundles/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/ResourceResolverMangleNamespacesTest.java
Thu Jul  4 04:41:34 2013
@@ -35,20 +35,20 @@ import org.mockito.MockitoAnnotations;
 /** Test ResourceResolverImpl.mangleNamespaces methods */
 public class ResourceResolverMangleNamespacesTest {
     private ResourceResolverImpl rr;
-    
+
     @Mock
     private Session mockedSession;
-    
+
     private Session activeSession;
-    
+
     public static final String NS_PREFIX = "testNS";
     public static final String NS_URL = "http://example.com/namespaces/testNS";
-    
-    @Before 
+
+    @Before
     public void setup() throws RepositoryException {
         MockitoAnnotations.initMocks(this);
         activeSession = mockedSession;
-        
+
         // Setup a ResourceResolverImpl with namespace mangling and unmangling
         final ResourceResolverFactoryActivator act = new ResourceResolverFactoryActivator()
{
             @Override
@@ -56,9 +56,9 @@ public class ResourceResolverMangleNames
                 return true;
             }
         };
-        
+
         Mockito.when(mockedSession.getNamespacePrefix(NS_PREFIX)).thenReturn(NS_URL);
-        
+
         final RootResourceProviderEntry rrpe = new RootResourceProviderEntry() {
             @Override
             @SuppressWarnings("unchecked")
@@ -69,66 +69,66 @@ public class ResourceResolverMangleNames
                 return super.adaptTo(ctx, type);
             }
         };
-        
-        final ResourceResolverFactoryImpl fac = new ResourceResolverFactoryImpl(act) {
+
+        final ResourceResolverFactoryImpl fac = new ResourceResolverFactoryImpl(act, null,
null) {
             @Override
             public RootResourceProviderEntry getRootProviderEntry() {
                 return rrpe;
             }
         };
-        
+
         rr = new ResourceResolverImpl(fac, new ResourceResolverContext(false, null, null));
     }
-    
-    @Test 
+
+    @Test
     public void testUrlWithPath() {
         assertEquals("http://example.com/some/path", rr.map("http://example.com/some/path"));
     }
-    
-    @Test 
+
+    @Test
     public void testMangleHttp() {
         assertEquals("http://example.com/path/_with_colon", rr.map("http://example.com/path/with:colon"));
     }
-    
-    @Test 
+
+    @Test
     public void testUnmangleHttp() {
         final Resource r = rr.resolve(null, "http://example.com/path/_with_mangling");
         assertEquals("/http://example.com/path/with:mangling", r.getPath());
     }
-    
-    @Test 
+
+    @Test
     public void testUnmangleNoSession() {
         activeSession = null;
         final Resource r = rr.resolve(null, "http://example.com/path/_with_mangling");
         assertEquals("/http://example.com/path/_with_mangling", r.getPath());
     }
-    
-    @Test 
+
+    @Test
     public void testManglePath() {
         assertEquals("/example.com/path/_with_colon", rr.map("/example.com/path/with:colon"));
     }
-    
-    @Test 
+
+    @Test
     public void testUnmanglePath() {
         final Resource r = rr.resolve(null, "/example.com/path/_with_mangling");
         assertEquals("/example.com/path/with:mangling", r.getPath());
     }
-    
-    @Test 
+
+    @Test
     public void testUrlNoPath() {
         assertEquals("http://withSlash.com/", rr.map("http://withSlash.com/"));
         assertEquals("http://noSlash.com", rr.map("http://noSlash.com"));
         assertEquals("http://nosuffix", rr.map("http://nosuffix"));
     }
-    
-    @Test 
+
+    @Test
     public void testWeirdCases() {
         assertEquals("http://foo", rr.map("http://foo"));
         assertEquals("http://", rr.map("http://"));
         assertEquals("http:/", rr.map("http:/"));
         assertEquals("http:", rr.map("http:"));
         assertEquals("http", rr.map("http"));
-        
+
         assertEquals("gopher://foo", rr.map("gopher://foo"));
         assertEquals("gopher://", rr.map("gopher://"));
         assertEquals("gopher:/", rr.map("gopher:/"));

Modified: sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderListTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderListTest.java?rev=1499653&r1=1499652&r2=1499653&view=diff
==============================================================================
--- sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderListTest.java
(original)
+++ sling/whiteboard/fmeschbe/deprecate_login_administrative/resourceresolver/src/test/java/org/apache/sling/resourceresolver/impl/helper/SortedProviderListTest.java
Thu Jul  4 04:41:34 2013
@@ -99,7 +99,7 @@ public class SortedProviderListTest {
         final AdaptableResourceProviderImpl rp3 = new AdaptableResourceProviderImpl(new String[]
{"/hello"}, 3L);
         final ResourceProviderImpl rp4 = new ResourceProviderImpl(new String[] {"/you"},
4L);
 
-        final ResourceResolverContext ctx = new ResourceResolverContext(false, null);
+        final ResourceResolverContext ctx = new ResourceResolverContext(false, null, null);
 
         final SortedProviderList<Adaptable> spl = new SortedProviderList<Adaptable>(Adaptable.class);
         check(spl, ctx);
@@ -131,7 +131,7 @@ public class SortedProviderListTest {
         final AdaptableResourceProviderImpl rp4 = new AdaptableResourceProviderImpl(new String[]
{"/a/a"}, 4L);
         final AdaptableResourceProviderImpl rp5 = new AdaptableResourceProviderImpl(new String[]
{"/all/or/nothing"}, 5L);
 
-        final ResourceResolverContext ctx = new ResourceResolverContext(false, null);
+        final ResourceResolverContext ctx = new ResourceResolverContext(false, null, null);
 
         final SortedProviderList<Adaptable> spl = new SortedProviderList<Adaptable>(Adaptable.class);
         check(spl, ctx);



Mime
View raw message