jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r949725 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Date Mon, 31 May 2010 12:09:18 GMT
Author: jukka
Date: Mon May 31 12:09:17 2010
New Revision: 949725

URL: http://svn.apache.org/viewvc?rev=949725&view=rev
Log:
JCR-2640: Internal repository context

Add the security manager to the repository context before initialising it to avoid problems
with implementations that require the manager to be present even before it has been fully
initialised. Such situations should ideally not exist, so leaving a FIXME comment in the code.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java

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=949725&r1=949724&r2=949725&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
Mon May 31 12:09:17 2010
@@ -344,7 +344,7 @@ public class RepositoryImpl extends Abst
             getSystemSearchManager(repConfig.getDefaultWorkspaceName());
 
             // Initialise the security manager;
-            context.setSecurityManager(createSecurityManager());
+            initSecurityManager();
             
             // after the workspace is initialized we pass a system session to
             // the virtual node type manager
@@ -449,15 +449,24 @@ public class RepositoryImpl extends Abst
 
     /**
      * Creates the {@link org.apache.jackrabbit.core.security.JackrabbitSecurityManager SecurityManager}
-     * of this <code>Repository</code>
+     * of this <code>Repository</code> and adds it to the repository context.
      *
-     * @return the security manager
      * @throws RepositoryException if an error occurs.
      */
-    private synchronized JackrabbitSecurityManager createSecurityManager()
-            throws RepositoryException {
+    private synchronized void initSecurityManager() throws RepositoryException {
         SecurityManagerConfig smc =
             getConfig().getSecurityConfig().getSecurityManagerConfig();
+        if (smc == null) {
+            log.debug("No configuration entry for SecurityManager. Using org.apache.jackrabbit.core.security.simple.SimpleSecurityManager");
+            securityMgr = new SimpleSecurityManager();
+        } else {
+            securityMgr = smc.newInstance(JackrabbitSecurityManager.class);
+        }
+
+        log.info("SecurityManager = " + securityMgr.getClass());
+
+        context.setSecurityManager(securityMgr);
+
         String workspaceName = getConfig().getDefaultWorkspaceName();
         if (smc != null && smc.getWorkspaceName() != null) {
             workspaceName = smc.getWorkspaceName();
@@ -467,17 +476,11 @@ public class RepositoryImpl extends Abst
         // not get disposed by workspace-janitor
         onSessionCreated(securitySession);
 
-        if (smc == null) {
-            log.debug("No configuration entry for SecurityManager. Using org.apache.jackrabbit.core.security.simple.SimpleSecurityManager");
-            securityMgr = new SimpleSecurityManager();
-        } else {
-            securityMgr = smc.newInstance(JackrabbitSecurityManager.class);
-        }
-
+        // FIXME: Note that this call must be done *after* the security
+        // 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, securitySession);
-        log.info("SecurityManager = " + securityMgr.getClass());
-
-        return securityMgr;
     }
 
     /**



Mime
View raw message