jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1543443 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/ jackrabbit-core/src/t...
Date Tue, 19 Nov 2013 14:40:32 GMT
Author: angela
Date: Tue Nov 19 14:40:31 2013
New Revision: 1543443

URL: http://svn.apache.org/r1543443
Log:
JCR-3697 : UserManager not supported error when trying to remove Node in 2.7.2

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManagerTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/TestAll.java
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml
Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepository.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepository.java?rev=1543443&r1=1543442&r2=1543443&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepository.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/JackrabbitRepository.java
Tue Nov 19 14:40:31 2013
@@ -32,6 +32,24 @@ import javax.jcr.Session;
 public interface JackrabbitRepository extends Repository {
 
     /**
+     * Key to a <code>boolean</code> descriptor. Returns <code>true</code>
if
+     * and only if user management is supported.
+     */
+    public static final String OPTION_USER_MANAGEMENT_SUPPORTED = "option.user.management.supported";
+
+    /**
+     * Key to a <code>boolean</code> descriptor. Returns <code>true</code>
if
+     * and only if principal management is supported.
+     */
+    public static final String OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED = "option.principal.management.supported";
+
+    /**
+     * Key to a <code>boolean</code> descriptor. Returns <code>true</code>
if
+     * and only if privilege management is supported.
+     */
+    public static final String OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED = "option.privilege.management.supported";
+
+    /**
      * Equivalent to {@code login(credentials, workspaceName)} except that the returned
      * Session instance contains the given extra session attributes in addition to any
      * included in the given Credentials instance. Attribute names from the credentials

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=1543443&r1=1543442&r2=1543443&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Tue Nov 19 14:40:31 2013
@@ -468,7 +468,31 @@ public class RepositoryImpl extends Abst
         // manager has been added to the repository context, since the
         // initialisation code may invoke code that depends on the presence
         // of a security manager. It would be better if this was not the case.
-        securityMgr.init(this, getSystemSession(workspaceName));
+        SystemSession systemSession = getSystemSession(workspaceName);
+        securityMgr.init(this, systemSession);
+
+        // initial security specific repository descriptors that are defined
+        // by JackrabbitRepository
+        ValueFactory vf = ValueFactoryImpl.getInstance();
+        boolean hasUserMgt;
+        try {
+            securityMgr.getUserManager(systemSession);
+            hasUserMgt = true;
+        } catch (RepositoryException e) {
+            hasUserMgt = false;
+        }
+        setDescriptor(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED, vf.createValue(hasUserMgt));
+
+        boolean hasPrincipalMgt;
+        try {
+            securityMgr.getPrincipalManager(systemSession);
+            hasPrincipalMgt = true;
+        } catch (RepositoryException e) {
+            hasPrincipalMgt = false;
+        }
+        setDescriptor(JackrabbitRepository.OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED, vf.createValue(hasPrincipalMgt));
+        setDescriptor(JackrabbitRepository.OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED, vf.createValue(true));
+
     }
 
     /**
@@ -1179,7 +1203,7 @@ public class RepositoryImpl extends Abst
      * <ul>
      * <li>Sets standard descriptors</li>
      * <li>{@link #getCustomRepositoryDescriptors()} is called
-     * afterwards in order to add custom/overwrite standard repository decriptors.</li>
+     * afterwards in order to add custom/overwrite standard repository descriptors.</li>
      * </ul>
      *
      * @throws RepositoryException

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=1543443&r1=1543442&r2=1543443&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
Tue Nov 19 14:40:31 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.security.user;
 
+import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
@@ -1155,11 +1156,14 @@ public class UserManagerImpl extends Pro
 
     //--------------------------------------------------------------------------
     public static boolean includesAdmin(NodeImpl node) throws RepositoryException {
-        UserManager uMgr = ((SessionImpl) node.getSession()).getUserManager();
-        if (uMgr instanceof UserManagerImpl) {
-            UserManagerImpl uMgrImpl = (UserManagerImpl) uMgr;
-            AuthorizableImpl admin = (AuthorizableImpl) uMgrImpl.getAuthorizable(uMgrImpl.adminId);
-            return Text.isDescendantOrEqual(node.getPath(), admin.getNode().getPath());
+        SessionImpl s = (SessionImpl) node.getSession();
+        if (s.getRepository().getDescriptorValue(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED).getBoolean())
{
+            UserManager uMgr = s.getUserManager();
+            if (uMgr instanceof UserManagerImpl) {
+                UserManagerImpl uMgrImpl = (UserManagerImpl) uMgr;
+                AuthorizableImpl admin = (AuthorizableImpl) uMgrImpl.getAuthorizable(uMgrImpl.adminId);
+                return Text.isDescendantOrEqual(node.getPath(), admin.getNode().getPath());
+            }
         }
         return false;
     }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManagerTest.java?rev=1543443&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManagerTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/SimpleSecurityManagerTest.java
Tue Nov 19 14:40:31 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.core.security.simple;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import junit.framework.TestCase;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+import org.junit.Test;
+
+public class SimpleSecurityManagerTest extends TestCase {
+
+    private Repository repository;
+
+    @Override
+    public void setUp() throws RepositoryException {
+        String file = "src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml";
+        RepositoryConfig config = RepositoryConfig.create(file, "jackrabbit-core/target/simple_repository");
+        repository = RepositoryImpl.create(config);
+    }
+
+    /**
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-3697">JCR-3697</a>
+     */
+    @Test
+    public void testRemove() throws RepositoryException {
+        Session s = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
+        Node n = s.getRootNode().addNode(("a"));
+        s.save();
+
+        n.remove();
+        s.save();
+    }
+}
\ No newline at end of file

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/TestAll.java?rev=1543443&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/TestAll.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/simple/TestAll.java
Tue Nov 19 14:40:31 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 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.
+ */
+package org.apache.jackrabbit.core.security.simple;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestAll extends TestCase {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("core.security.simple tests");
+
+        suite.addTestSuite(SimpleSecurityManagerTest.class);
+
+        return suite;
+    }
+}

Added: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml?rev=1543443&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/security/simple/simple_repository.xml
Tue Nov 19 14:40:31 2013
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+   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.
+-->
+<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 2.4//EN"
+                            "http://jackrabbit.apache.org/dtd/repository-2.4.dtd">
+<Repository>
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+
+    <Security appName="Jackrabbit">
+        <SecurityManager class="org.apache.jackrabbit.core.security.simple.SimpleSecurityManager">
+        </SecurityManager>
+
+        <AccessManager class="org.apache.jackrabbit.core.security.simple.SimpleAccessManager">
+        </AccessManager>
+
+        <LoginModule class="org.apache.jackrabbit.core.security.simple.SimpleLoginModule">
+        </LoginModule>
+    </Security>
+
+    <!--
+        location of workspaces root directory and name of default workspace
+    -->
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/>
+    <!--
+        workspace configuration template:
+        used to create the initial workspace if there's no workspace yet
+    -->
+    <Workspace name="${wsp.name}">
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${wsp.home}/db;create=true"/>
+          <param name="schemaObjectPrefix" value="${wsp.name}_"/>
+        </PersistenceManager>
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <param name="path" value="${wsp.home}/index"/>
+        </SearchIndex>
+    </Workspace>
+
+    <!--
+        Configures the versioning
+    -->
+    <Versioning rootPath="${rep.home}/version">
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/version" />
+        </FileSystem>
+        <PersistenceManager class="org.apache.jackrabbit.core.persistence.pool.DerbyPersistenceManager">
+          <param name="url" value="jdbc:derby:${rep.home}/version/db;create=true"/>
+          <param name="schemaObjectPrefix" value="version_"/>
+        </PersistenceManager>
+    </Versioning>
+
+    <!--
+        Search index for content that is shared repository wide
+        (/jcr:system tree, contains mainly versions)
+    -->
+    <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+        <param name="path" value="${rep.home}/repository/index"/>
+    </SearchIndex>
+
+</Repository>



Mime
View raw message