deepyaraj commented on a change in pull request #88:
URL: https://github.com/apache/qpid-broker-j/pull/88#discussion_r645473474



##########
File path: 
broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
##########
@@ -104,17 +105,21 @@ public synchronized void setGroupFile(String groupFile) 
throws IOException
     @Override
     public synchronized void addUserToGroup(String user, String group)
     {
-        Set<String> users = 
_groupToUserMap.get(keySearch(_groupToUserMap.keySet(), group));
-        if (users == null)
+        Set<String> groupUsers = 
_groupToUserMap.get(keySearch(_groupToUserMap.keySet(), group));
+        if (groupUsers == null)
         {
             throw new IllegalArgumentException("Group "
                                                + group
                                                + " does not exist so could not 
add "
                                                + user
                                                + " to it");
         }
+        else if (groupUsers.contains(keySearch(_userToGroupMap.keySet(), 
user)))
+        {
+            throw new IllegalConfigurationException(String.format("Group 
member with name'%s' already exists", user));
+        }
 
-        users.add(keySearch(users, user));
+        groupUsers.add(keySearch(groupUsers, user));

Review comment:
       This call to keysearch is made explicitly not to add duplicate for a 
case sensitive provider. So replacing this will lead to undesriable results

##########
File path: 
broker-core/src/main/java/org/apache/qpid/server/security/group/FileGroupDatabase.java
##########
@@ -104,17 +105,21 @@ public synchronized void setGroupFile(String groupFile) 
throws IOException
     @Override
     public synchronized void addUserToGroup(String user, String group)
     {
-        Set<String> users = 
_groupToUserMap.get(keySearch(_groupToUserMap.keySet(), group));
-        if (users == null)
+        Set<String> groupUsers = 
_groupToUserMap.get(keySearch(_groupToUserMap.keySet(), group));
+        if (groupUsers == null)
         {
             throw new IllegalArgumentException("Group "
                                                + group
                                                + " does not exist so could not 
add "
                                                + user
                                                + " to it");
         }
+        else if (groupUsers.contains(keySearch(_userToGroupMap.keySet(), 
user)))
+        {
+            throw new IllegalConfigurationException(String.format("Group 
member with name'%s' already exists", user));
+        }
 
-        users.add(keySearch(users, user));
+        groupUsers.add(keySearch(groupUsers, user));
 
         Set<String> groups = 
_userToGroupMap.get(keySearch(_userToGroupMap.keySet(), user));

Review comment:
       Done!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to