jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1814698 - in /jackrabbit/commons/filevault/trunk: vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/ vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/ vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ vau...
Date Thu, 09 Nov 2017 03:49:15 GMT
Author: tripod
Date: Thu Nov  9 03:49:15 2017
New Revision: 1814698

URL: http://svn.apache.org/viewvc?rev=1814698&view=rev
Log:
JCRVLT-227 Import fail if user does not have access to the root path

Modified:
    jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java
    jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/InstallContextImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java

Modified: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java
Thu Nov  9 03:49:15 2017
@@ -19,7 +19,6 @@ package org.apache.jackrabbit.vault.cli;
 
 import java.io.File;
 
-import javax.jcr.Node;
 import javax.jcr.Session;
 
 import org.apache.commons.cli2.Argument;
@@ -71,8 +70,7 @@ public class CmdImport extends AbstractJ
         }
 
         Session s = vaultFile.getFileSystem().getAggregateManager().getSession();
-        Node importRoot = s.getNode(vaultFile.getPath());
-        importer.run(archive, importRoot);
+        importer.run(archive, s, vaultFile.getPath());
         VaultFsApp.log.info("Importing done.");
     }
 

Modified: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java
Thu Nov  9 03:49:15 2017
@@ -21,7 +21,6 @@ import java.io.File;
 import java.io.InputStream;
 
 import javax.jcr.ImportUUIDBehavior;
-import javax.jcr.Node;
 import javax.jcr.Session;
 
 import org.apache.commons.cli2.Argument;
@@ -115,8 +114,7 @@ public class CmdImportCli extends Abstra
                 importer.getOptions().setListener(new DefaultProgressListener());
             }
             Session s = vaultFile.getFileSystem().getAggregateManager().getSession();
-            Node importRoot = s.getNode(vaultFile.getPath());
-            importer.run(archive, importRoot);
+            importer.run(archive, s, vaultFile.getPath());
         } finally {
             archive.close();
         }

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/Importer.java
Thu Nov  9 03:49:15 2017
@@ -298,7 +298,6 @@ public class Importer {
     }
 
     /**
-     /**
      * Runs the importer
      *
      * @param archive the archive to import
@@ -312,6 +311,23 @@ public class Importer {
      */
     public void run(Archive archive, Node importRoot)
             throws IOException, RepositoryException, ConfigurationException {
+        run(archive, importRoot.getSession(), importRoot.getPath());
+    }
+
+    /**
+     * Runs the importer with the given session.
+     *
+     * @param archive the archive to import
+     * @param session the session importing the archive
+     * @param parentPath the repository parent path where the archive will be imported
+     * @throws IOException if an I/O error occurs
+     * @throws RepositoryException if a repository error occurs
+     * @throws ConfigurationException if the importer is not properly configured
+     *
+     * @since 2.7.0
+     */
+    public void run(Archive archive, Session session,  String parentPath)
+            throws IOException, RepositoryException, ConfigurationException {
         this.archive = archive;
 
         // init tracker
@@ -380,13 +396,11 @@ public class Importer {
             filterTree.put(set.getRoot(), set);
         }
 
-        String parentPath = importRoot.getPath();
-        if (parentPath.equals("/")) {
+        if ("/".equals(parentPath)) {
             parentPath = "";
         }
 
         track("Collecting import information...", "");
-        Session session = importRoot.getSession();
         TxInfo root = prepare(archive.getJcrRoot(), parentPath, new SessionNamespaceResolver(session));
         if (filter!=null && filter.getFilterSets() != null && filter.getFilterSets().size()
> 0 ) {
             root = postFilter(root);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/io/package-info.java
Thu Nov  9 03:49:15 2017
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-@Version("2.6.0")
+@Version("2.7.0")
 package org.apache.jackrabbit.vault.fs.io;
 
 import org.osgi.annotation.versioning.Version;
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/InstallContextImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/InstallContextImpl.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/InstallContextImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/InstallContextImpl.java
Thu Nov  9 03:49:15 2017
@@ -17,7 +17,6 @@
 
 package org.apache.jackrabbit.vault.packaging.impl;
 
-import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
@@ -34,7 +33,7 @@ public class InstallContextImpl implemen
 
     private final Session session;
 
-    private final Node importRoot;
+    private final String importRootPath;
 
     private final VaultPackage pack;
 
@@ -44,11 +43,11 @@ public class InstallContextImpl implemen
 
     private final InstallHookProcessor hooks;
 
-    public InstallContextImpl(Node importRoot, VaultPackage pack,
+    public InstallContextImpl(Session session, String importRootPath, VaultPackage pack,
                               Importer importer, InstallHookProcessor hooks)
             throws RepositoryException {
-        this.session = importRoot.getSession();
-        this.importRoot = importRoot;
+        this.session = session;
+        this.importRootPath = importRootPath;
         this.pack = pack;
         this.importer = importer;
         this.hooks = hooks;
@@ -82,7 +81,7 @@ public class InstallContextImpl implemen
         return hooks;
     }
 
-    protected Node getImportRoot() {
-        return importRoot;
+    protected String getImportRootPath() {
+        return importRootPath;
     }
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageDefinitionImpl.java
Thu Nov  9 03:49:15 2017
@@ -279,13 +279,11 @@ public class JcrPackageDefinitionImpl im
         filter.add(new PathFilterSet(rootPath));
 
         try {
-            Node rootNode = session.getNode(rootPath);
-
             Importer importer = new Importer();
             // disable saving
             importer.getOptions().setAutoSaveThreshold(Integer.MAX_VALUE);
             importer.getOptions().setFilter(filter);
-            importer.run(archive, rootNode);
+            importer.run(archive, session, rootPath);
 
             // refresh defNode if it was replaced during unwrap
             defNode = session.getNode(rootPath);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/JcrPackageImpl.java
Thu Nov  9 03:49:15 2017
@@ -71,7 +71,6 @@ import org.apache.jackrabbit.vault.packa
 import org.apache.jackrabbit.vault.packaging.VaultPackage;
 import org.apache.jackrabbit.vault.packaging.Version;
 import org.apache.jackrabbit.vault.packaging.events.PackageEvent;
-import org.apache.jackrabbit.vault.packaging.registry.RegisteredPackage;
 import org.apache.jackrabbit.vault.packaging.registry.impl.JcrPackageRegistry;
 import org.apache.jackrabbit.vault.packaging.registry.impl.JcrRegisteredPackage;
 import org.apache.jackrabbit.vault.util.JcrConstants;

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/packaging/impl/ZipVaultPackage.java
Thu Nov  9 03:49:15 2017
@@ -202,7 +202,7 @@ public class ZipVaultPackage extends Pac
             }
         }
 
-        return new InstallContextImpl(session.getRootNode(), this, importer, hooks);
+        return new InstallContextImpl(session, "/", this, importer, hooks);
     }
 
     /**
@@ -229,7 +229,7 @@ public class ZipVaultPackage extends Pac
                 throw new PackageException("Import aborted during prepare phase.");
             }
             try {
-                importer.run(archive, ctx.getImportRoot());
+                importer.run(archive, ctx.getSession(), ctx.getImportRootPath());
             } catch (Exception e) {
                 log.error("Error during install.", e);
                 ctx.setPhase(InstallContext.Phase.INSTALL_FAILED);

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/ImportTests.java
Thu Nov  9 03:49:15 2017
@@ -18,11 +18,19 @@
 package org.apache.jackrabbit.vault.packaging.integration;
 
 import java.io.IOException;
+import java.security.Principal;
 
 import javax.jcr.Node;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.jackrabbit.core.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
 import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
 import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
@@ -266,5 +274,68 @@ public class ImportTests extends Integra
         assertNodeExists("/tmp/package.zip/jcr:content/vlt:definition/thumbnail.png");
     }
 
+    @Test
+    public void testImportWithoutRootAccess() throws IOException, RepositoryException, ConfigurationException
{
+        // Create test user
+        UserManager userManager = ((JackrabbitSession)admin).getUserManager();
+        String userId = "user1";
+        String userPwd = "pwd1";
+        User user1 = userManager.createUser(userId, userPwd);
+        Principal principal1 = user1.getPrincipal();
+
+        // Create /tmp folder
+        admin.getRootNode().addNode("tmp");
+        admin.save();
+
+        // Setup test user ACLs such that the
+        // root node is not accessible
+        AccessControlUtils.addAccessControlEntry(admin, null, principal1, new String[]{"jcr:namespaceManagement","jcr:nodeTypeDefinitionManagement"},
true);
+        AccessControlUtils.addAccessControlEntry(admin, "/", principal1, new String[]{"jcr:all"},
false);
+        AccessControlUtils.addAccessControlEntry(admin, "/tmp", principal1, new String[]{"jcr:all"},
true);
+        admin.save();
+
+        // Import with a session associated to the test user
+        Session session = repository.login(new SimpleCredentials(userId, userPwd.toCharArray()));
+        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tmp.zip"));
+        archive.open(true);
+        ImportOptions opts = getDefaultOptions();
+        Importer importer = new Importer(opts);
+        importer.run(archive, session, "/");
+        session.logout();
+
+        assertNodeExists("/tmp/foo/bar/tobi");
+    }
+
+    @Test
+    public void testImportWithoutRootAndTmpAccess() throws IOException, RepositoryException,
ConfigurationException {
+        // Create test user
+        UserManager userManager = ((JackrabbitSession)admin).getUserManager();
+        String userId = "user1";
+        String userPwd = "pwd1";
+        User user1 = userManager.createUser(userId, userPwd);
+        Principal principal1 = user1.getPrincipal();
+
+        // Create /tmp folder
+        admin.getRootNode().addNode("tmp").addNode("foo");
+        admin.save();
+
+        // Setup test user ACLs such that the
+        // root node is not accessible
+        AccessControlUtils.addAccessControlEntry(admin, null, principal1, new String[]{"jcr:namespaceManagement","jcr:nodeTypeDefinitionManagement"},
true);
+        AccessControlUtils.addAccessControlEntry(admin, "/", principal1, new String[]{"jcr:all"},
false);
+        AccessControlUtils.addAccessControlEntry(admin, "/tmp/foo", principal1, new String[]{"jcr:all"},
true);
+        admin.save();
+
+        // Import with a session associated to the test user
+        Session session = repository.login(new SimpleCredentials(userId, userPwd.toCharArray()));
+        ZipArchive archive = new ZipArchive(getTempFile("testpackages/tmp_foo.zip"));
+        archive.open(true);
+        ImportOptions opts = getDefaultOptions();
+        Importer importer = new Importer(opts);
+        importer.run(archive, session, "/");
+        session.logout();
+
+        assertNodeExists("/tmp/foo/bar/tobi");
+    }
 
 }
\ No newline at end of file

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java?rev=1814698&r1=1814697&r2=1814698&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestPackageInstall.java
Thu Nov  9 03:49:15 2017
@@ -19,19 +19,30 @@ package org.apache.jackrabbit.vault.pack
 
 import java.io.File;
 import java.io.IOException;
+import java.security.Principal;
 
 import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.jcr.nodetype.NodeType;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.api.JackrabbitSession;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
 import org.apache.jackrabbit.vault.fs.io.ImportOptions;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipArchive;
 import org.apache.jackrabbit.vault.packaging.InstallContext;
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.apache.jackrabbit.vault.packaging.PackageId;
+import org.apache.jackrabbit.vault.packaging.impl.JcrPackageManagerImpl;
 import org.apache.tika.io.IOUtils;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -576,6 +587,91 @@ public class TestPackageInstall extends
         assertProperty("/testroot/a/jcr:isCheckedOut", "false");
     }
 
+    /**
+     * Tests if package installation works w/o RW access to / and /tmp.
+     * this currently fails, due to the creation of the snapshot.
+     * also see {@link TestNoRootAccessExport#exportNoRootAccess()}
+     */
+    @Test
+    @Ignore("JCRVLT-100")
+    public void testInstallWithoutRootAndTmpAccess() throws IOException, RepositoryException,
ConfigurationException, PackageException {
+        JcrPackage pack = packMgr.upload(getStream("testpackages/tmp_foo.zip"), true, true);
+        assertNotNull(pack);
+        assertTrue(pack.isValid());
+        PackageId id = pack.getPackage().getId();
+        pack.close();
+
+        // Create test user
+        UserManager userManager = ((JackrabbitSession)admin).getUserManager();
+        String userId = "user1";
+        String userPwd = "pwd1";
+        User user1 = userManager.createUser(userId, userPwd);
+        Principal principal1 = user1.getPrincipal();
+
+        // Create /tmp folder
+        admin.getRootNode().addNode("tmp").addNode("foo");
+        admin.save();
+
+        // Setup test user ACLs such that the
+        // root node is not accessible
+        AccessControlUtils.addAccessControlEntry(admin, null, principal1, new String[]{"jcr:namespaceManagement","jcr:nodeTypeDefinitionManagement"},
true);
+        AccessControlUtils.addAccessControlEntry(admin, "/", principal1, new String[]{"jcr:all"},
false);
+        AccessControlUtils.addAccessControlEntry(admin, "/etc/packages", principal1, new
String[]{"jcr:all"}, true);
+        AccessControlUtils.addAccessControlEntry(admin, "/tmp/foo", principal1, new String[]{"jcr:all"},
true);
+        admin.save();
+
+        Session session = repository.login(new SimpleCredentials(userId, userPwd.toCharArray()));
+        JcrPackageManagerImpl userPackMgr = new JcrPackageManagerImpl(session);
+        pack = userPackMgr.open(id);
+        ImportOptions opts = getDefaultOptions();
+        pack.install(opts);
+        pack.close();
+        session.logout();
+
+        assertNodeExists("/tmp/foo/bar/tobi");
+    }
+
+    /**
+     * Test if package extraction works w/o RW access to / and /tmp.
+     */
+    @Test
+    public void testExtractWithoutRootAndTmpAccess() throws IOException, RepositoryException,
ConfigurationException, PackageException {
+        JcrPackage pack = packMgr.upload(getStream("testpackages/tmp_foo.zip"), true, true);
+        assertNotNull(pack);
+        assertTrue(pack.isValid());
+        PackageId id = pack.getPackage().getId();
+        pack.close();
+
+        // Create test user
+        UserManager userManager = ((JackrabbitSession)admin).getUserManager();
+        String userId = "user1";
+        String userPwd = "pwd1";
+        User user1 = userManager.createUser(userId, userPwd);
+        Principal principal1 = user1.getPrincipal();
+
+        // Create /tmp folder
+        admin.getRootNode().addNode("tmp").addNode("foo");
+        admin.save();
+
+        // Setup test user ACLs such that the
+        // root node is not accessible
+        AccessControlUtils.addAccessControlEntry(admin, null, principal1, new String[]{"jcr:namespaceManagement","jcr:nodeTypeDefinitionManagement"},
true);
+        AccessControlUtils.addAccessControlEntry(admin, "/", principal1, new String[]{"jcr:all"},
false);
+        AccessControlUtils.addAccessControlEntry(admin, "/etc/packages", principal1, new
String[]{"jcr:all"}, true);
+        AccessControlUtils.addAccessControlEntry(admin, "/tmp/foo", principal1, new String[]{"jcr:all"},
true);
+        admin.save();
+
+        Session session = repository.login(new SimpleCredentials(userId, userPwd.toCharArray()));
+        JcrPackageManagerImpl userPackMgr = new JcrPackageManagerImpl(session);
+        pack = userPackMgr.open(id);
+        ImportOptions opts = getDefaultOptions();
+        pack.extract(opts);
+        pack.close();
+        session.logout();
+
+        assertNodeExists("/tmp/foo/bar/tobi");
+    }
+
 
     // todo: upload with version
     // todo: rename



Mime
View raw message