jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r995401 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
Date Thu, 09 Sep 2010 12:29:39 GMT
Author: mduerig
Date: Thu Sep  9 12:29:39 2010
New Revision: 995401

URL: http://svn.apache.org/viewvc?rev=995401&view=rev
Log:
JCR-2743: ClassCastException in GroupImpl.isCyclicMembership

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java?rev=995401&r1=995400&r2=995401&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Thu Sep  9 12:29:39 2010
@@ -16,28 +16,6 @@
  */
 package org.apache.jackrabbit.core.security.user;
 
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.Node;
-import javax.jcr.Property;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.UserManager;
@@ -50,13 +28,34 @@ import org.apache.jackrabbit.commons.ite
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
 import org.apache.jackrabbit.core.session.SessionContext;
-import org.apache.jackrabbit.core.session.SessionOperation;
 import org.apache.jackrabbit.core.session.SessionWriteOperation;
 import org.apache.jackrabbit.spi.commons.iterator.Iterators;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
 /**
  * GroupImpl...
  */
@@ -403,7 +402,7 @@ class GroupImpl extends AuthorizableImpl
                 Value[] members = node.getProperty(P_MEMBERS).getValues();
 
                 if (includeIndirect) {
-                    return includeIndirect(toAuthorizables(members, type));
+                    return includeIndirect(toAuthorizables(members, type), type);
                 }
                 else {
                     return toAuthorizables(members, type);
@@ -500,7 +499,7 @@ class GroupImpl extends AuthorizableImpl
             if (node.hasNode(N_MEMBERS)) {
                 PropertySequence members = getPropertySequence(node.getNode(N_MEMBERS), userManager);
                 if (includeIndirect) {
-                    return includeIndirect(toAuthorizables(members.iterator(), type));
+                    return includeIndirect(toAuthorizables(members.iterator(), type), type);
                 }
                 else {
                     return toAuthorizables(members.iterator(), type);
@@ -519,7 +518,7 @@ class GroupImpl extends AuthorizableImpl
      * Returns an iterator of authorizables which includes all indirect members of the given
iterator
      * of authorizables.
      */
-    private Iterator<Authorizable> includeIndirect(final Iterator<Authorizable>
authorizables) {
+    private Iterator<Authorizable> includeIndirect(final Iterator<Authorizable>
authorizables, final int type) {
         Iterator<Iterator<Authorizable>> indirectMembers = new Iterator<Iterator<Authorizable>>()
{
             public boolean hasNext() {
                 return authorizables.hasNext();
@@ -540,7 +539,7 @@ class GroupImpl extends AuthorizableImpl
             private Iterator<Authorizable> indirect(Authorizable authorizable) {
                 if (authorizable.isGroup()) {
                     try {
-                        return ((Group) authorizable).getMembers();
+                        return ((GroupImpl) authorizable).getMembers(true, type);
                     }
                     catch (RepositoryException e) {
                         log.warn("Could not determine members of " + authorizable, e);

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java?rev=995401&r1=995400&r2=995401&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/GroupTest.java
Thu Sep  9 12:29:39 2010
@@ -405,6 +405,29 @@ public class GroupTest extends AbstractU
         }
     }
 
+    public void testCyclicGroups() throws AuthorizableExistsException, RepositoryException,
NotExecutableException {
+        Group group1 = null;
+        Group group2 = null;
+        Group group3 = null;
+        try {
+            group1 = userMgr.createGroup(getTestPrincipal());
+            group2 = userMgr.createGroup(getTestPrincipal());
+            group3 = userMgr.createGroup(getTestPrincipal());
+
+            group1.addMember(getTestUser(superuser));
+            group2.addMember(getTestUser(superuser));
+
+            assertTrue(group1.addMember(group2));
+            assertTrue(group2.addMember(group3));
+            assertFalse(group3.addMember(group1));
+        }
+        finally {
+            if (group1 != null) group1.remove();
+            if (group2 != null) group2.remove();
+            if (group3 != null) group3.remove();
+        }
+    }
+
     public void testRemoveMemberTwice() throws NotExecutableException, RepositoryException
{
         User auth = getTestUser(superuser);
         Group newGroup = null;



Mime
View raw message