jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1483556 [2/2] - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/ oak-core/src/main/java/org/apache/jackrabbit/oak/core/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/ oak-core/src/main/java/org/apache...
Date Thu, 16 May 2013 20:44:16 GMT
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlValidatorTest.java
Thu May 16 20:44:15 2013
@@ -16,10 +16,6 @@
  */
 package org.apache.jackrabbit.oak.security.authorization;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.security.Principal;
 
 import org.apache.jackrabbit.JcrConstants;
@@ -34,6 +30,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class AccessControlValidatorTest extends AbstractAccessControlTest implements AccessControlConstants
{
 
     private final String testName = "testRoot";
@@ -288,7 +288,7 @@ public class AccessControlValidatorTest 
 
     @Test
     public void testAbstractPrivilege() throws Exception {
-        PrivilegeManager pMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root,
getNamePathMapper());
+        PrivilegeManager pMgr = getPrivilegeManager(root);
         pMgr.registerPrivilege("abstractPrivilege", true, new String[0]);
 
         NodeUtil acl = createAcl();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ReadPolicyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ReadPolicyTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ReadPolicyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/ReadPolicyTest.java
Thu May 16 20:44:15 2013
@@ -21,6 +21,7 @@ import javax.jcr.security.AccessControlP
 
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.authorization.AbstractAccessControlTest;
+import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConstants;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,7 +40,7 @@ public class ReadPolicyTest extends Abst
     public void before() throws Exception {
         super.before();
 
-        ConfigurationParameters options = getSecurityProvider().getAccessControlConfiguration().getConfigurationParameters();
+        ConfigurationParameters options = getConfig(AccessControlConfiguration.class).getParameters();
         readPaths = options.getConfigValue(AccessControlConstants.PARAM_READ_PATHS, AccessControlConstants.DEFAULT_READ_PATHS);
     }
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/evaluation/Jr2CompatibilityTest.java
Thu May 16 20:44:15 2013
@@ -105,7 +105,7 @@ public class Jr2CompatibilityTest extend
             testRoot.commit();
         } finally {
             root.refresh();
-            Authorizable user = getUserManager().getAuthorizable("a");
+            Authorizable user = getUserManager(root).getAuthorizable("a");
             if (user != null) {
                 user.remove();
                 root.commit();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/CompiledPermissionImplTest.java
Thu May 16 20:44:15 2013
@@ -36,6 +36,7 @@ import org.apache.jackrabbit.oak.core.Im
 import org.apache.jackrabbit.oak.core.ImmutableTree;
 import org.apache.jackrabbit.oak.core.TreeTypeProvider;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
+import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConstants;
 import org.apache.jackrabbit.oak.security.authorization.restriction.RestrictionProviderImpl;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeBits;
@@ -122,10 +123,29 @@ public class CompiledPermissionImplTest 
     @Override
     protected SecurityProvider getSecurityProvider() {
         return new SecurityProviderImpl() {
+
+            @Nonnull
+            @Override
+            public Iterable<? extends SecurityConfiguration> getConfigurations() {
+                List<SecurityConfiguration> configs = new ArrayList<SecurityConfiguration>();
+                for (SecurityConfiguration sc : super.getConfigurations()) {
+                    if (sc instanceof AccessControlConfiguration) {
+                        configs.add(new OpenAccessControlConfiguration());
+                    } else {
+                        configs.add(sc);
+                    }
+                }
+                return configs;
+            }
+
             @Nonnull
             @Override
-            public AccessControlConfiguration getAccessControlConfiguration() {
-                return new OpenAccessControlConfiguration();
+            public <T> T getConfiguration(Class<T> configClass) {
+                if (AccessControlConfiguration.class == configClass) {
+                    return (T) new OpenAccessControlConfiguration();
+                } else {
+                    return super.getConfiguration(configClass);
+                }
             }
         };
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/permission/PermissionHookTest.java
Thu May 16 20:44:15 2013
@@ -96,7 +96,7 @@ public class PermissionHookTest extends 
             }
 
             for (Principal principal : principals) {
-                getUserManager().getAuthorizable(principal).remove();
+                getUserManager(root).getAuthorizable(principal).remove();
             }
             root.commit();
         } finally {
@@ -121,7 +121,7 @@ public class PermissionHookTest extends 
     private void createPrincipals() throws Exception {
         if (principals.isEmpty()) {
             for (int i = 0; i < 10; i++) {
-                Group gr = getUserManager().createGroup("testGroup"+i);
+                Group gr = getUserManager(root).createGroup("testGroup"+i);
                 principals.add(gr.getPrincipal());
             }
             root.commit();

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImplTest.java
Thu May 16 20:44:15 2013
@@ -80,7 +80,7 @@ public class PrincipalProviderImplTest e
 
         Group everyoneGroup = null;
         try {
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             everyoneGroup = userMgr.createGroup(EveryonePrincipal.NAME);
             root.commit();
 
@@ -98,7 +98,7 @@ public class PrincipalProviderImplTest e
     public void testFindUserPrincipal() throws Exception {
         User testUser = null;
         try {
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             testUser = userMgr.createUser("TestUser", "pw");
             root.commit();
 
@@ -126,7 +126,7 @@ public class PrincipalProviderImplTest e
     public void testFindGroupPrincipal() throws Exception {
         Group testGroup = null;
         try {
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             testGroup = userMgr.createGroup("TestGroup");
             root.commit();
 
@@ -194,7 +194,7 @@ public class PrincipalProviderImplTest e
         User testUser = null;
         Group testGroup = null;
         try {
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             testUser = userMgr.createUser("TestUser", "pw");
             testGroup = userMgr.createGroup("TestGroup");
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableImplTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/AuthorizableImplTest.java
Thu May 16 20:44:15 2013
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.AbstractSecurityTest;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -44,7 +45,7 @@ public class AuthorizableImplTest extend
     public void before() throws Exception {
         super.before();
 
-        userMgr = getUserManager();
+        userMgr = getUserManager(root);
         testUser = getTestUser();
         testGroup = userMgr.createGroup("testGroup");
         root.commit();
@@ -89,7 +90,7 @@ public class AuthorizableImplTest extend
      */
     @Test
     public void testNotEqualAuthorizables() throws Exception {
-        UserManager otherUserManager = getSecurityProvider().getUserConfiguration().getUserManager(root,
getNamePathMapper());
+        UserManager otherUserManager = getUserConfiguration().getUserManager(root, getNamePathMapper());
         Authorizable user = otherUserManager.getAuthorizable(testUser.getID());
         Authorizable group = otherUserManager.getAuthorizable(testGroup.getID());
 
@@ -125,7 +126,7 @@ public class AuthorizableImplTest extend
             assertEquals(entry.getKey().hashCode(), entry.getValue().hashCode());
         }
 
-        UserManager otherUserManager = getSecurityProvider().getUserConfiguration().getUserManager(root,
getNamePathMapper());
+        UserManager otherUserManager = getUserConfiguration().getUserManager(root, getNamePathMapper());
         user = otherUserManager.getAuthorizable(testUser.getID());
         group = otherUserManager.getAuthorizable(testGroup.getID());
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserInitializerTest.java
Thu May 16 20:44:15 2013
@@ -16,18 +16,9 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.jcr.SimpleCredentials;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
@@ -60,6 +51,14 @@ import org.apache.jackrabbit.oak.util.Tr
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 /**
  * @since OAK 1.0
  */
@@ -73,8 +72,8 @@ public class UserInitializerTest extends
     public void before() throws Exception {
         super.before();
 
-        userMgr = getUserManager();
-        config = getUserConfiguration().getConfigurationParameters();
+        userMgr = getUserManager(root);
+        config = getUserConfiguration().getParameters();
     }
 
     @Test
@@ -160,7 +159,8 @@ public class UserInitializerTest extends
         });
         try {
             Root root = cs.getLatestRoot();
-            UserManager umgr = sp.getUserConfiguration().getUserManager(root, NamePathMapper.DEFAULT);
+            UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
+            UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
             Authorizable adminUser = umgr.getAuthorizable("admin");
             assertNotNull(adminUser);
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserValidatorTest.java
Thu May 16 20:44:15 2013
@@ -102,7 +102,7 @@ public class UserValidatorTest extends A
     @Test
     public void createWithoutPrincipalName() throws Exception {
         try {
-            User user = getUserManager().createUser("withoutPrincipalName", "pw");
+            User user = getUserManager(root).createUser("withoutPrincipalName", "pw");
             Tree tree = root.getTree(userPath);
             tree.removeProperty(REP_PRINCIPAL_NAME);
             root.commit();
@@ -118,7 +118,7 @@ public class UserValidatorTest extends A
     @Test
     public void createWithInvalidUUID() throws Exception {
         try {
-            User user = getUserManager().createUser("withInvalidUUID", "pw");
+            User user = getUserManager(root).createUser("withInvalidUUID", "pw");
             Tree tree = root.getTree(userPath);
             tree.setProperty(JcrConstants.JCR_UUID, UUID.randomUUID().toString());
             root.commit();
@@ -191,7 +191,7 @@ public class UserValidatorTest extends A
     public void testRemoveAdminUser() throws Exception {
         try {
             String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             Authorizable admin = userMgr.getAuthorizable(adminId);
             if (admin == null) {
                 admin = userMgr.createUser(adminId, adminId);
@@ -212,7 +212,7 @@ public class UserValidatorTest extends A
     public void testDisableAdminUser() throws Exception {
         try {
             String adminId = getConfig().getConfigValue(PARAM_ADMIN_ID, DEFAULT_ADMIN_ID);
-            UserManager userMgr = getUserManager();
+            UserManager userMgr = getUserManager(root);
             Authorizable admin = userMgr.getAuthorizable(adminId);
             if (admin == null) {
                 admin = userMgr.createUser(adminId, adminId);
@@ -283,7 +283,7 @@ public class UserValidatorTest extends A
         Group group2 = null;
         Group group3 = null;
         
-        UserManager userMgr = getUserManager();
+        UserManager userMgr = getUserManager(root);
         try {
             group1 = userMgr.createGroup("group1");
             group2 = userMgr.createGroup("group2");
@@ -312,6 +312,6 @@ public class UserValidatorTest extends A
     }
 
     private ConfigurationParameters getConfig() {
-        return getUserConfiguration().getConfigurationParameters();
+        return getUserConfiguration().getParameters();
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/query/UserQueryManagerTest.java
Thu May 16 20:44:15 2013
@@ -49,9 +49,9 @@ public class UserQueryManagerTest extend
     public void before() throws Exception {
         super.before();
 
-        UserManager userMgr = getUserManager();
+        UserManager userMgr = getUserManager(root);
         user = getTestUser();
-        queryMgr = new UserQueryManager(userMgr, namePathMapper, getUserConfiguration().getConfigurationParameters(),
root);
+        queryMgr = new UserQueryManager(userMgr, namePathMapper, getUserConfiguration().getParameters(),
root);
 
         valueFactory = new ValueFactoryImpl(root.getBlobFactory(), namePathMapper);
         propertyName = "testProperty";

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModuleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModuleTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModuleTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authentication/external/ExternalLoginModuleTest.java
Thu May 16 20:44:15 2013
@@ -58,7 +58,7 @@ public class ExternalLoginModuleTest ext
         for (ExternalGroup group : TestLoginModule.externalGroups) {
             ids.add(group.getId());
         }
-        userManager = getUserManager();
+        userManager = getUserManager(root);
     }
 
     @After

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
Thu May 16 20:44:15 2013
@@ -89,7 +89,7 @@ public abstract class AbstractAccessCont
         for (int i = 0; i < 3; i++) {
             entries.add(new ACE(
                     new PrincipalImpl("testPrincipal" + i),
-                    new Privilege[]{getPrivilegeManager().getPrivilege(PrivilegeConstants.JCR_READ)},
+                    new Privilege[]{getPrivilegeManager(root).getPrivilege(PrivilegeConstants.JCR_READ)},
                     true, null, namePathMapper));
         }
         return entries;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlTest.java
Thu May 16 20:44:15 2013
@@ -46,7 +46,7 @@ public abstract class AbstractAccessCont
 
     protected RestrictionProvider getRestrictionProvider() {
         if (restrictionProvider == null) {
-            restrictionProvider = getSecurityProvider().getAccessControlConfiguration().getRestrictionProvider();
+            restrictionProvider = getConfig(AccessControlConfiguration.class).getRestrictionProvider();
         }
         return restrictionProvider;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/AccessControlActionTest.java
Thu May 16 20:44:15 2013
@@ -55,7 +55,7 @@ public class AccessControlActionTest ext
 
     @Test
     public void testAccessControlActionForUser() throws Exception {
-        UserManager userMgr = getUserManager();
+        UserManager userMgr = getUserManager(root);
         User u = null;
         try {
             String uid = "actionTestUser";
@@ -74,7 +74,7 @@ public class AccessControlActionTest ext
 
     @Test
     public void testAccessControlAction() throws Exception {
-        UserManager userMgr = getUserManager();
+        UserManager userMgr = getUserManager(root);
         Group gr = null;
         try {
             gr = userMgr.createGroup("actionTestGroup");
@@ -97,6 +97,6 @@ public class AccessControlActionTest ext
             assertTrue(policies[0] instanceof AccessControlList);
             AccessControlList acl = (AccessControlList) policies[0];
             assertEquals(1, acl.getAccessControlEntries().length);
-            assertArrayEquals(new Privilege[]{getPrivilegeManager().getPrivilege(expectedPrivName)},
acl.getAccessControlEntries()[0].getPrivileges());
+            assertArrayEquals(new Privilege[]{getPrivilegeManager(root).getPrivilege(expectedPrivName)},
acl.getAccessControlEntries()[0].getPrivileges());
     }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
Thu May 16 20:44:15 2013
@@ -16,15 +16,9 @@
  */
 package org.apache.jackrabbit.oak.spi.security.user.action;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-
 import javax.annotation.Nonnull;
 import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
@@ -45,6 +39,11 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 public class PasswordValidationActionTest extends AbstractSecurityTest {
 
     private PasswordValidationAction pwAction = new PasswordValidationAction();
@@ -57,7 +56,7 @@ public class PasswordValidationActionTes
     public void before() throws Exception {
         super.before();
 
-        user = (User) getUserManager().getAuthorizable(adminSession.getAuthInfo().getUserID());
+        user = (User) getUserManager(root).getAuthorizable(adminSession.getAuthInfo().getUserID());
 
         testAction.reset();
         pwAction.setConstraint("^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z]).*");
@@ -84,7 +83,7 @@ public class PasswordValidationActionTes
 
     @Test
     public void testActionIsCalled() throws Exception {
-        testUser = getUserManager().createUser("testUser", "testUser12345");
+        testUser = getUserManager(root).createUser("testUser", "testUser12345");
         root.commit();
         assertEquals(1, testAction.onCreateCalled);
 
@@ -128,7 +127,7 @@ public class PasswordValidationActionTes
     @Test
     public void testPasswordValidationActionOnCreate() throws Exception {
         String hashed = PasswordUtility.buildPasswordHash("DWkej32H");
-        testUser = getUserManager().createUser("testuser", hashed);
+        testUser = getUserManager(root).createUser("testuser", hashed);
         root.commit();
 
         String pwValue = root.getTree(testUser.getPath()).getProperty(UserConstants.REP_PASSWORD).getValue(Type.STRING);
@@ -138,7 +137,7 @@ public class PasswordValidationActionTes
 
     @Test
     public void testPasswordValidationActionOnChange() throws Exception {
-        testUser = getUserManager().createUser("testuser", "testPw123456");
+        testUser = getUserManager(root).createUser("testuser", "testPw123456");
         root.commit();
         try {
             pwAction.setConstraint("abc");
@@ -188,22 +187,23 @@ public class PasswordValidationActionTes
             this.actions = new AuthorizableAction[]{pwAction, testAction};
         }
 
-        @Nonnull
-        @Override
-        public UserConfiguration getUserConfiguration() {
-            return new UserConfigurationImpl(this) {
-
-                @Nonnull
-                @Override
-                public AuthorizableActionProvider getAuthorizableActionProvider() {
-                    return new AuthorizableActionProvider() {
-                        @Override
-                        public List<AuthorizableAction> getAuthorizableActions() {
-                            return Arrays.asList(actions);
-                        }
-                    };
-                }
-            };
+        public <T> T getConfiguration(Class<T> configClass) {
+            if (UserConfiguration.class == configClass) {
+                return (T) new UserConfigurationImpl(this) {
+                    @Nonnull
+                    @Override
+                    public AuthorizableActionProvider getAuthorizableActionProvider() {
+                        return new AuthorizableActionProvider() {
+                            @Override
+                            public List<AuthorizableAction> getAuthorizableActions()
{
+                                return Arrays.asList(actions);
+                            }
+                        };
+                    }
+                };
+            } else {
+                return super.getConfiguration(configClass);
+            }
         }
     }
 }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1483556&r1=1483555&r2=1483556&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Thu May 16 20:44:15 2013
@@ -54,8 +54,11 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.observation2.ObservationManagerImpl2;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.spi.security.SecurityConfiguration;
-import org.apache.jackrabbit.oak.spi.security.SecurityProvider;
+import org.apache.jackrabbit.oak.spi.security.authorization.AccessControlConfiguration;
 import org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider;
+import org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration;
+import org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeConfiguration;
+import org.apache.jackrabbit.oak.spi.security.user.UserConfiguration;
 import org.apache.jackrabbit.oak.spi.xml.ProtectedItemImporter;
 
 import static com.google.common.base.Preconditions.checkNotNull;
@@ -197,8 +200,7 @@ public abstract class SessionContext imp
     @Nonnull
     public AccessControlManager getAccessControlManager() throws RepositoryException {
         if (accessControlManager == null) {
-            SecurityProvider securityProvider = repository.getSecurityProvider();
-            accessControlManager = securityProvider.getAccessControlConfiguration().getAccessControlManager(delegate.getRoot(),
namePathMapper);
+            accessControlManager = getConfig(AccessControlConfiguration.class).getAccessControlManager(delegate.getRoot(),
namePathMapper);
         }
         return accessControlManager;
     }
@@ -206,8 +208,7 @@ public abstract class SessionContext imp
     @Nonnull
     public PrincipalManager getPrincipalManager() {
         if (principalManager == null) {
-            SecurityProvider securityProvider = repository.getSecurityProvider();
-            principalManager = securityProvider.getPrincipalConfiguration()
+            principalManager = getConfig(PrincipalConfiguration.class)
                     .getPrincipalManager(delegate.getRoot(), namePathMapper);
         }
         return principalManager;
@@ -216,8 +217,7 @@ public abstract class SessionContext imp
     @Nonnull
     public UserManager getUserManager() {
         if (userManager == null) {
-            SecurityProvider securityProvider = repository.getSecurityProvider();
-            userManager = securityProvider.getUserConfiguration().getUserManager(delegate.getRoot(),
namePathMapper);
+            userManager = getConfig(UserConfiguration.class).getUserManager(delegate.getRoot(),
namePathMapper);
         }
         return userManager;
     }
@@ -225,8 +225,7 @@ public abstract class SessionContext imp
     @Nonnull
     public PrivilegeManager getPrivilegeManager() {
         if (privilegeManager == null) {
-            SecurityProvider securityProvider = repository.getSecurityProvider();
-            privilegeManager = securityProvider.getPrivilegeConfiguration().getPrivilegeManager(delegate.getRoot(),
namePathMapper);
+            privilegeManager = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(delegate.getRoot(),
namePathMapper);
         }
         return privilegeManager;
     }
@@ -235,7 +234,7 @@ public abstract class SessionContext imp
     public List<ProtectedItemImporter> getProtectedItemImporters() {
         // TODO: take non-security related importers into account as well (proper configuration)
         List<ProtectedItemImporter> importers = new ArrayList<ProtectedItemImporter>();
-        for (SecurityConfiguration sc : repository.getSecurityProvider().getSecurityConfigurations())
{
+        for (SecurityConfiguration sc : repository.getSecurityProvider().getConfigurations())
{
             importers.addAll(sc.getProtectedItemImporters());
         }
         return importers;
@@ -368,9 +367,13 @@ public abstract class SessionContext imp
     @Nonnull
     private PermissionProvider getPermissionProvider() {
         if (permissionProvider == null) {
-            SecurityProvider securityProvider = repository.getSecurityProvider();
-            permissionProvider = securityProvider.getAccessControlConfiguration().getPermissionProvider(delegate.getRoot(),
delegate.getAuthInfo().getPrincipals());
+            permissionProvider = getConfig(AccessControlConfiguration.class).getPermissionProvider(delegate.getRoot(),
delegate.getAuthInfo().getPrincipals());
         }
         return permissionProvider;
     }
+
+    @Nonnull
+    private <T> T getConfig(Class<T> clss) {
+        return repository.getSecurityProvider().getConfiguration(clss);
+    }
 }



Mime
View raw message