Author: ieb Date: Thu Mar 28 02:02:19 2013 New Revision: 1461921 URL: http://svn.apache.org/r1461921 Log: SLING-2788 Implemented SLingRepositoryImpl based on OSGi repository in Oak. This replaces the sling-oak bundle and ensures node types and namespaces are loaded.... although there are problems with the order in which they are loaded at present.
Added: sling/whiteboard/ieb/oak/launchpad/ sling/whiteboard/ieb/oak/launchpad/pom.xml - copied, changed from r1460496, sling/whiteboard/ieb/oak/pom.xml sling/whiteboard/ieb/oak/launchpad/src/ sling/whiteboard/ieb/oak/launchpad/src/main/ sling/whiteboard/ieb/oak/launchpad/src/main/resources/ sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/ sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/ sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config - copied, changed from r1460496, sling/whiteboard/ieb/oak/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config sling/whiteboard/ieb/oak/server/ sling/whiteboard/ieb/oak/server/pom.xml (with props) sling/whiteboard/ieb/oak/server/src/ sling/whiteboard/ieb/oak/server/src/main/ sling/whiteboard/ieb/oak/server/src/main/java/ sling/whiteboard/ieb/oak/server/src/main/java/org/ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java (with props) sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java (with props) sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java (with props) sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java (with props) Removed: sling/whiteboard/ieb/oak/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config Modified: sling/whiteboard/ieb/oak/pom.xml Copied: sling/whiteboard/ieb/oak/launchpad/pom.xml (from r1460496, sling/whiteboard/ieb/oak/pom.xml) URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/launchpad/pom.xml?p2=sling/whiteboard/ieb/oak/launchpad/pom.xml&p1=sling/whiteboard/ieb/oak/pom.xml&r1=1460496&r2=1461921&rev=1461921&view=diff ============================================================================== --- sling/whiteboard/ieb/oak/pom.xml (original) +++ sling/whiteboard/ieb/oak/launchpad/pom.xml Thu Mar 28 02:02:19 2013 @@ -30,9 +30,9 @@ </description> <scm> - <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak</connection> - <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak</developerConnection> - <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak</url> + <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak/launchpad</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak/launchpad</developerConnection> + <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/launchpad</url> </scm> <build> @@ -76,26 +76,12 @@ <version>7-SNAPSHOT</version> </defaultBundleList> <bundleExclusions> - <!-- - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-api</artifactId> - <version>2.4.2</version> - </bundle> - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-commons</artifactId> - <version>2.4.2</version> - </bundle> - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-rmi</artifactId> - <version>2.4.2</version> - </bundle> - --> + <!-- Updated by additional Bundle <bundle> <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-api</artifactId> <version>2.4.2</version> </bundle> + Updated by additional Bundle <bundle> <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-jcr-commons</artifactId> <version>2.4.2</version> + </bundle> Updated by additional Bundle <bundle> <groupId>org.apache.jackrabbit</groupId> + <artifactId>jackrabbit-jcr-rmi</artifactId> <version>2.4.2</version> </bundle> --> <bundle> <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-spi</artifactId> @@ -143,38 +129,18 @@ </bundle> </bundleExclusions> <additionalBundles> - <!-- this imports org.apache.jackrabbit.tests which should be optional --> - <![CDATA[ -diff --git a/oak-sling/pom.xml b/oak-sling/pom.xml -index 1fd27cb..6eeca57 100644 ---- a/oak-sling/pom.xml -+++ b/oak-sling/pom.xml -@@ -41,6 +41,10 @@ - <Export-Package> - ! - </Export-Package> -+ <Import-Package> -+ org.apache.jackrabbit.test;resolution:=optional, -+ * -+ </Import-Package> - <Embed-Dependency> - oak-jcr - </Embed-Dependency> - -]]> <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-sling</artifactId> - <version>0.7-SNAPSHOT</version> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.oak.server</artifactId> + <version>0.0.1-SNAPSHOT</version> </bundle> - <!-- - This is embedded in oak-sling <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-jcr</artifactId> - <version>0.7-SNAPSHOT</version> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.base</artifactId> + <version>2.1.3-SNAPSHOT</version> </bundle> - --> + <!-- This is embedded in oak-sling <bundle> <groupId>org.apache.jackrabbit</groupId> + <artifactId>oak-jcr</artifactId> <version>0.7-SNAPSHOT</version> </bundle> --> <bundle> <groupId>org.apache.jackrabbit</groupId> <artifactId>oak-core</artifactId> @@ -258,12 +224,13 @@ index 1fd27cb..6eeca57 100644 <classifier>app</classifier> <scope>provided</scope> </dependency> - - <!-- dependencies from here are only present to allow inspection of the bundles in Eclipse. Not required explicitly for the build. --> + + <!-- dependencies from here are only present to allow inspection + of the bundles in Eclipse. Not required explicitly for the build. --> <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-sling</artifactId> - <version>0.7-SNAPSHOT</version> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.oak.server</artifactId> + <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.jackrabbit</groupId> Copied: sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config (from r1460496, sling/whiteboard/ieb/oak/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config) URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config?p2=sling/whiteboard/ieb/oak/launchpad/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config&p1=sling/whiteboard/ieb/oak/src/main/resources/resources/config/org.apache.jackrabbit.mk.osgi.MicroKernelService.config&r1=1460496&r2=1461921&rev=1461921&view=diff ============================================================================== (empty) Modified: sling/whiteboard/ieb/oak/pom.xml URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/pom.xml?rev=1461921&r1=1461920&r2=1461921&view=diff ============================================================================== --- sling/whiteboard/ieb/oak/pom.xml (original) +++ sling/whiteboard/ieb/oak/pom.xml Thu Mar 28 02:02:19 2013 @@ -17,16 +17,16 @@ <groupId>org.apache.sling</groupId> <artifactId>sling</artifactId> <version>15</version> - <relativePath>../../parent/pom.xml</relativePath> + <relativePath>../parent/pom.xml</relativePath> </parent> - <artifactId>org.apache.sling.launchpad.oak</artifactId> - <packaging>jar</packaging> - <version>7-SNAPSHOT</version> + <artifactId>org.apache.sling.launchpad.oak-builder</artifactId> + <packaging>pom</packaging> + <version>0.0.1-SNAPSHOT</version> - <name>Apache Sling Launchpad Oak</name> + <name>Apache Sling Launchpad Oak Builder</name> <description> - Sling Launchpad Oak module + Sling Launchpad Oak builder </description> <scm> @@ -34,251 +34,9 @@ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak</developerConnection> <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak</url> </scm> + <modules> + <module>server</module> + <module>launchpad</module> + </modules> - <build> - <plugins> - <!-- this ensures that the MANIFEST.MF unpacked from the lauchpad - base app bundle is used. --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> - <manifest> - <addDefaultImplementationEntries> - true - </addDefaultImplementationEntries> - </manifest> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.sling</groupId> - <artifactId>maven-launchpad-plugin</artifactId> - <version>2.1.2</version> - <extensions>true</extensions> - <executions> - <execution> - <id>prepare-package-jar</id> - <goals> - <goal>prepare-package</goal> - </goals> - <configuration> - <packaging>jar</packaging> - </configuration> - </execution> - </executions> - <!-- Bind to the launchpad bundle list this jar should be - based on. --> - <configuration> - <defaultBundleList> - <version>7-SNAPSHOT</version> - </defaultBundleList> - <bundleExclusions> - <!-- - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-api</artifactId> - <version>2.4.2</version> - </bundle> - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-commons</artifactId> - <version>2.4.2</version> - </bundle> - Updated by additional Bundle - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-rmi</artifactId> - <version>2.4.2</version> - </bundle> - --> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-spi</artifactId> - <version>2.4.2</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-spi-commons</artifactId> - <version>2.4.2</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-webdav</artifactId> - <version>2.4.2</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.jcr.jackrabbit.accessmanager</artifactId> - <version>2.1.1-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId> - <version>2.1.1-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.jcr.jackrabbit.usermanager</artifactId> - <version>2.1.1-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.extensions.webconsolesecurityprovider</artifactId> - <version>1.0.0</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.jcr.davex</artifactId> - <version>1.1.0</version> - </bundle> - <bundle> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.jcr.webdav</artifactId> - <version>2.1.2</version> - </bundle> - </bundleExclusions> - <additionalBundles> - <!-- this imports org.apache.jackrabbit.tests which should be optional --> - <![CDATA[ -diff --git a/oak-sling/pom.xml b/oak-sling/pom.xml -index 1fd27cb..6eeca57 100644 ---- a/oak-sling/pom.xml -+++ b/oak-sling/pom.xml -@@ -41,6 +41,10 @@ - <Export-Package> - ! - </Export-Package> -+ <Import-Package> -+ org.apache.jackrabbit.test;resolution:=optional, -+ * -+ </Import-Package> - <Embed-Dependency> - oak-jcr - </Embed-Dependency> - -]]> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-sling</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <!-- - This is embedded in oak-sling - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-jcr</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - --> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-core</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-commons</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-mk-api</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-mk</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-mk-remote</artifactId> - <version>0.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-api</artifactId> - <version>2.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-commons</artifactId> - <version>2.7-SNAPSHOT</version> - </bundle> - <bundle> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - <version>13.0.1</version> - </bundle> - - </additionalBundles> - </configuration> - </plugin> - </plugins> - </build> - <reporting> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <configuration> - <!-- No javadocs --> - <excludePackageNames> - org.apache.sling - </excludePackageNames> - </configuration> - </plugin> - </plugins> - </reporting> - - <dependencies> - - <!-- The basic Sling WebApp --> - <!-- this order is important. The maven-launchpad-plugin tried to - work out the base, which by default is the webapp since war normally comes - after jar (or perhaps webapp comes after app). Putting these dependencies - in in this order causes the app to get unpacked. --> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.launchpad.base</artifactId> - <version>2.5.1-SNAPSHOT</version> - <classifier>webapp</classifier> - <type>war</type> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.launchpad.base</artifactId> - <version>2.5.1-SNAPSHOT</version> - <classifier>app</classifier> - <scope>provided</scope> - </dependency> - - <!-- dependencies from here are only present to allow inspection of the bundles in Eclipse. Not required explicitly for the build. --> - <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-sling</artifactId> - <version>0.7-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>oak-jcr</artifactId> - <version>0.7-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-api</artifactId> - <version>2.7-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.apache.jackrabbit</groupId> - <artifactId>jackrabbit-jcr-commons</artifactId> - <version>2.7-SNAPSHOT</version> - </dependency> - </dependencies> </project> Added: sling/whiteboard/ieb/oak/server/pom.xml URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/pom.xml?rev=1461921&view=auto ============================================================================== --- sling/whiteboard/ieb/oak/server/pom.xml (added) +++ sling/whiteboard/ieb/oak/server/pom.xml Thu Mar 28 02:02:19 2013 @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling</artifactId> + <version>15</version> + <relativePath>../../../parent/pom.xml</relativePath> + </parent> + + <artifactId>org.apache.sling.oak.server</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>bundle</packaging> + + <name>Apache Sling Oak Server</name> + <description> + This bundle provides a SlingRepository based on Apache Oak. + </description> + + <scm> + <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak/server</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/oak/server</developerConnection> + <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server</url> + </scm> + <properties> + <sling.java.version>6</sling.java.version> + </properties> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-scr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Import-Package> + org.apache.jackrabbit.test;resolution:=optional, + * + </Import-Package> + <Package-Private> + org.apache.sling.oak.server.* + </Package-Private> + <Embed-Transitive>true</Embed-Transitive> + <Embed-Dependency> + oak-jcr + </Embed-Dependency> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.jackrabbit</groupId> + <artifactId>oak-jcr</artifactId> + <version>0.7-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.api</artifactId> + <version>2.3.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.api</artifactId> + <version>2.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.base</artifactId> + <version>2.1.3-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.resource</artifactId> + <version>2.2.4</version> + <scope>provided</scope> + </dependency> + + <!-- OSGi Libraries not included here --> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.compendium</artifactId> + </dependency> + + <!-- servlet API for the web console plugin --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.scr.annotations</artifactId> + </dependency> + <dependency> + <groupId>biz.aQute</groupId> + <artifactId>bndlib</artifactId> + </dependency> + + <!-- testing --> + <!-- using mockito because its a bit more relaxed and makes it easier to maintain + the test cases if dependencies change --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.8.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + </dependencies> +</project> Propchange: sling/whiteboard/ieb/oak/server/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/whiteboard/ieb/oak/server/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java?rev=1461921&view=auto ============================================================================== --- sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java (added) +++ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java Thu Mar 28 02:02:19 2013 @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The SF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.sling.oak.server; + +import org.apache.jackrabbit.oak.spi.security.SecurityProvider; + +/** + * Provides security providers to the SlingRespository, internal API at present. + */ +public interface InternalSecurityProviderFactory { + + /** + * @return a security provider. + */ + SecurityProvider getSecurityProvider(); + +} Propchange: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/InternalSecurityProviderFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Added: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java?rev=1461921&view=auto ============================================================================== --- sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java (added) +++ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java Thu Mar 28 02:02:19 2013 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The SF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.sling.oak.server; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Service; +import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; +import org.apache.jackrabbit.oak.spi.security.SecurityProvider; +import org.osgi.service.component.ComponentContext; + +/** + * Holder for the security provider so it can be replaced with ease in the future. + */ +@Component(immediate = true, metatype = true) +@Service(value = { InternalSecurityProviderFactory.class }) +public class SecurityProviderFactoryImpl implements InternalSecurityProviderFactory { + + /** + * Security provider. + */ + private SecurityProvider securityProvider; + + /** + * Activate the component. + * @param componentContext component context. + */ + @Activate + public void activate(ComponentContext componentContext) { + securityProvider = new OpenSecurityProvider(); + } + + /** + * Deactivate the component. + * @param componentContext component context. + */ + @Deactivate + public void deactivate(ComponentContext componentContext) { + securityProvider = null; + } + + @Override + public SecurityProvider getSecurityProvider() { + return securityProvider; + } + + +} Propchange: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SecurityProviderFactoryImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java?rev=1461921&view=auto ============================================================================== --- sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java (added) +++ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java Thu Mar 28 02:02:19 2013 @@ -0,0 +1,286 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The SF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package org.apache.sling.oak.server; + +import java.util.Dictionary; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; + +import javax.jcr.Credentials; +import javax.jcr.LoginException; +import javax.jcr.NoSuchWorkspaceException; +import javax.jcr.Repository; +import javax.jcr.RepositoryException; +import javax.jcr.Session; +import javax.jcr.SimpleCredentials; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Property; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.Service; +import org.apache.jackrabbit.oak.api.ContentRepository; +import org.apache.jackrabbit.oak.jcr.osgi.OsgiRepository; +import org.apache.jackrabbit.oak.spi.security.SecurityProvider; +import org.apache.sling.jcr.api.SlingRepository; +import org.apache.sling.jcr.base.AbstractNamespaceMappingRepository; +import org.apache.sling.jcr.resource.JcrResourceConstants; +import org.osgi.service.component.ComponentContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A Sling repository implementation that wraps the Oak OSGi repository + * implementation from the Oak project. The configuration of the repository and + * the underlying node storage is performed in the Oak components and not here. + */ +@Component(immediate = true, metatype = true) +@Service(value = { SlingRepository.class, Repository.class }) +public class SlingRepositoryImpl extends AbstractNamespaceMappingRepository + implements SlingRepository { + + /** + * Default anon user id. + */ + private static final String DEFAULT_ANONYMOUS_USER = "anon"; + + /** + * Default anon user password. + */ + private static final String DEFAULT_ANONYMOUS_PASS = "anon"; + + /** + * Default admin user id. + */ + private static final String DEFAULT_ADMIN_USER = "admin"; + + /** + * Default admin user password. + */ + private static final String DEFAULT_ADMIN_PASS = "admin"; + + /** + * OSGi property name for anon user id. + */ + @Property(value = DEFAULT_ANONYMOUS_USER) + public static final String PROPERTY_ANONYMOUS_USER = "anonymous.name"; + + /** + * OSGi property name for anon user password. + */ + @Property(value = DEFAULT_ANONYMOUS_PASS) + public static final String PROPERTY_ANONYMOUS_PASS = "anonymous.password"; + + /** + * OSGi property name for admin user id. + */ + @Property(value = DEFAULT_ADMIN_USER) + public static final String PROPERTY_ADMIN_USER = "admin.name"; + + /** + * OSGi property name for admin password. + */ + @Property(value = DEFAULT_ADMIN_PASS) + public static final String PROPERTY_ADMIN_PASS = "admin.password"; + + /** + * The logger. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(SlingRepositoryImpl.class); + + /** + * Content repository provided by Oak. + */ + @Reference + private ContentRepository repository; + + /** + * Factory for the security provider. + */ + @Reference + private InternalSecurityProviderFactory securityProviderFactory; + + /** + * Executor for the content repository. + */ + private ScheduledExecutorService executor; + + /** + * security provider for the content repository. + */ + private SecurityProvider securityProvider; + + /** + * The configured oak repository ready for use. + */ + private OsgiRepository oakRepository; + + /** + * Anon user id. + */ + private String anonUserID; + + /** + * Anon user password. + */ + private char[] anonPassword; + + /** + * Admin user id. + */ + private String adminUserID; + + /** + * Admin user password. + */ + private char[] adminPassword; + + /** + * Dummy property holding the sling folder type ensuring that the resource + * bundle is present. If its not present, there is a risk that on activate + * the standard Sling CND files wont be available to add to the repo, which + * (on certain Operating systems) will cause a startup order leaving the + * repo in an invalid state. Putting the property here + */ + private String slingFolderType; + + /** + * @param componentContext component context. + */ + @Activate + public void activate(ComponentContext componentContext) { + @SuppressWarnings("unchecked") + Dictionary<String, Object> properties = componentContext.getProperties(); + anonUserID = getProperty(properties, PROPERTY_ANONYMOUS_USER, + DEFAULT_ANONYMOUS_USER); + anonPassword = getProperty(properties, PROPERTY_ANONYMOUS_PASS, + DEFAULT_ANONYMOUS_PASS).toCharArray(); + adminUserID = getProperty(properties, PROPERTY_ADMIN_USER, + DEFAULT_ADMIN_USER); + adminPassword = getProperty(properties, PROPERTY_ADMIN_PASS, + DEFAULT_ADMIN_PASS).toCharArray(); + securityProvider = securityProviderFactory.getSecurityProvider(); + executor = Executors.newScheduledThreadPool(1); + oakRepository = new OsgiRepository(repository, executor, + securityProvider); + // This import ensures that the resource bundle containing the node + // types is present + // before this component starts up. It may be unnecessary, but this + // ensures its there. + slingFolderType = JcrResourceConstants.NT_SLING_FOLDER; + LOGGER.debug( + "Bound sucessfully to jcr resource bundle, Sling Folder type is {} ", + slingFolderType); + super.setup(componentContext.getBundleContext()); + } + + /** + * Get a property with a default. + * + * @param <T> the type of the property. + * @param properties the properties. + * @param name the name of the property. + * @param defaultValue the default value. + * @return the property, or if null the default. + */ + private <T> T getProperty(Dictionary<String, Object> properties, + String name, T defaultValue) { + @SuppressWarnings("unchecked") + T v = (T) properties.get(name); + if (v == null) { + v = defaultValue; + } + return v; + } + + /** + * Deactivate the component. + * + * @param componentContext the component context. + */ + @Deactivate + public void deactivate(ComponentContext componentContext) { + super.tearDown(); + oakRepository = null; + securityProvider = null; + executor.shutdown(); + executor = null; + } + + @Override + public String[] getDescriptorKeys() { + return oakRepository.getDescriptorKeys(); + } + + @Override + public String getDescriptor(String key) { + return oakRepository.getDescriptor(key); + } + + @Override + public Session login(Credentials credentials, String workspaceName) + throws LoginException, NoSuchWorkspaceException, + RepositoryException { + return getNamespaceAwareSession(oakRepository.login(credentials, + workspaceName)); + } + + @Override + public Session login(Credentials credentials) throws LoginException, + RepositoryException { + return login(credentials, null); + } + + @Override + public Session login(String workspaceName) throws LoginException, + NoSuchWorkspaceException, RepositoryException { + return login(getAnonCredentials(), workspaceName); + } + + @Override + public Session login() throws LoginException, RepositoryException { + return login(getAnonCredentials(), null); + } + + @Override + public String getDefaultWorkspace() { + return "default"; + } + + @Override + public Session loginAdministrative(String workspace) + throws RepositoryException { + return login(getAdminCredentials(), workspace); + } + + /** + * @return admin credentials. + */ + private Credentials getAdminCredentials() { + return new SimpleCredentials(adminUserID, adminPassword); + } + + /** + * @return anon credentials. + */ + private Credentials getAnonCredentials() { + return new SimpleCredentials(anonUserID, anonPassword); + } + +} Propchange: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/SlingRepositoryImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Added: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java?rev=1461921&view=auto ============================================================================== --- sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java (added) +++ sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java Thu Mar 28 02:02:19 2013 @@ -0,0 +1,5 @@ +/** + * Contains in implementation of a SlingRepository based on Apache Oak. + * The package is not exported. + */ +package org.apache.sling.oak.server; Propchange: sling/whiteboard/ieb/oak/server/src/main/java/org/apache/sling/oak/server/package-info.java ------------------------------------------------------------------------------ svn:eol-style = native