jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r896532 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java
Date Wed, 06 Jan 2010 16:57:00 GMT
Author: angela
Date: Wed Jan  6 16:56:58 2010
New Revision: 896532

URL: http://svn.apache.org/viewvc?rev=896532&view=rev
Log:
JCR-2452 - DefaultPrincipalProvider#collectGroupMembership puts wrong principal instance to
the cache

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java?rev=896532&r1=896531&r2=896532&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProvider.java
Wed Jan  6 16:56:58 2010
@@ -280,7 +280,13 @@
             try {
                 final Authorizable auth = userManager.getAuthorizable(princ);
                 if (auth != null) {
-                    addToCache(princ);
+                    /*
+                    make sure the principal is contained in the cache.
+                    however, avoid putting the given 'princ' but assert that
+                    the cached principal is obtained with the system session
+                    used to deliver principals with this provider implementation.
+                    */
+                    addToCache(auth.getPrincipal());
                     Iterator<Group> itr = auth.memberOf();
                     while (itr.hasNext()) {
                         Group group = itr.next();

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java?rev=896532&r1=896531&r2=896532&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/principal/DefaultPrincipalProviderTest.java
Wed Jan  6 16:56:58 2010
@@ -21,11 +21,13 @@
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.core.security.user.UserManagerImpl;
+import org.apache.jackrabbit.core.security.TestPrincipal;
 import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.RepositoryException;
 import java.security.Principal;
 import java.util.Properties;
+import java.util.Set;
 
 /**
  * <code>DefaultPrincipalProviderTest</code>...
@@ -102,4 +104,20 @@
             save(superuser);
         }
     }
+
+    /**
+     *
+     * @throws Exception
+     */
+    public void testCacheDoesntContainTestPrincipalImpl() throws Exception {
+        Set<Principal> principals = getPrincipalSetFromSession(superuser);
+        for (Principal p : principals) {
+            Principal testPrinc = new TestPrincipal(p.getName());
+            principalProvider.getGroupMembership(testPrinc);
+            Principal fromProvider = ((DefaultPrincipalProvider) principalProvider).providePrincipal(p.getName());
+
+            assertNotSame(testPrinc, fromProvider);
+            assertFalse(fromProvider instanceof TestPrincipal);
+        }
+    }
 }
\ No newline at end of file



Mime
View raw message