jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1333811 - /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
Date Fri, 04 May 2012 08:30:21 GMT
Author: angela
Date: Fri May  4 08:30:20 2012
New Revision: 1333811

URL: http://svn.apache.org/viewvc?rev=1333811&view=rev
Log:
OAK-50 : User management (WIP)

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java?rev=1333811&r1=1333810&r2=1333811&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
Fri May  4 08:30:20 2012
@@ -108,24 +108,25 @@ class GroupImpl extends AuthorizableImpl
             log.warn("Invalid Authorizable: {}", authorizable);
             return false;
         }
-        if (isEveryone() || ((AuthorizableImpl) authorizable).isEveryone()) {
-            return false;
-        }
 
-        AuthorizableImpl authImpl = ((AuthorizableImpl) authorizable);
-        Node memberNode = authImpl.getNode();
-        if (memberNode.isSame(getNode())) {
-            String msg = "Attempt to add a group as member of itself (" + getID() + ").";
-            log.warn(msg);
+        AuthorizableImpl authorizableImpl = ((AuthorizableImpl) authorizable);
+        if (isEveryone() || authorizableImpl.isEveryone()) {
             return false;
         }
 
-        if (authImpl.isGroup() && ((GroupImpl) authImpl).isMember(this)) {
-            log.warn("Attempt to create circular group membership.");
-            return false;
+        if (authorizableImpl.isGroup()) {
+            if (getID().equals(authorizableImpl.getID())) {
+                String msg = "Attempt to add a group as member of itself (" + getID() + ").";
+                log.warn(msg);
+                return false;
+            }
+            if (((Group) authorizableImpl).isMember(this)) {
+                log.warn("Attempt to create circular group membership.");
+                return false;
+            }
         }
 
-        return getUserManager().getMembershipManager().addMember(this, authImpl);
+        return getUserManager().getMembershipManager().addMember(this, authorizableImpl);
     }
 
     /**



Mime
View raw message