directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smckin...@apache.org
Subject directory-fortress-core git commit: FC-75 - Add Role grouping mechanism
Date Sat, 14 May 2016 22:32:57 GMT
Repository: directory-fortress-core
Updated Branches:
  refs/heads/master a199f7a7d -> 015dfdf82


 FC-75 - Add Role grouping mechanism


Project: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/commit/015dfdf8
Tree: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/tree/015dfdf8
Diff: http://git-wip-us.apache.org/repos/asf/directory-fortress-core/diff/015dfdf8

Branch: refs/heads/master
Commit: 015dfdf8287a924150920c871d4c206e107151c6
Parents: a199f7a
Author: Shawn McKinney <smckinney@apache.org>
Authored: Sat May 14 17:17:57 2016 -0500
Committer: Shawn McKinney <smckinney@apache.org>
Committed: Sat May 14 17:17:57 2016 -0500

----------------------------------------------------------------------
 .../fortress/core/impl/GroupMgrImpl.java        | 28 ++++++++++++++++++--
 .../fortress/core/GroupMgrConsole.java          | 25 +++++++++++++----
 2 files changed, 46 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/015dfdf8/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
index 8e7639c..e27f25e 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupMgrImpl.java
@@ -63,7 +63,14 @@ public class GroupMgrImpl extends Manageable implements GroupMgr, Serializable
         
         if(!group.isMemberDn())
         {
-            loadUserDns( group );
+            if( group.getType() == Group.Type.ROLE )
+            {
+                loadRoleDns( group );
+            }
+            else
+            {
+                loadUserDns( group );
+            }
         }
 
         return GROUP_P.add( group );
@@ -152,7 +159,7 @@ public class GroupMgrImpl extends Manageable implements GroupMgr, Serializable
     {
         String methodName = "findWithUsers";
         assertContext(CLS_NM, methodName, user, GlobalErrIds.USER_NULL);
-        checkAccess(CLS_NM, methodName);
+        checkAccess( CLS_NM, methodName );
         loadUserDn( user );
         
         return GROUP_P.search( user );
@@ -225,6 +232,23 @@ public class GroupMgrImpl extends Manageable implements GroupMgr, Serializable
         }
     }
 
+    private void loadRoleDns( Group group ) throws SecurityException
+    {
+        if( CollectionUtils.isNotEmpty( group.getMembers() ))
+        {
+            ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();
+            List<String> roleDns = new ArrayList<String>();
+
+            for( String member : group.getMembers() )
+            {
+                Role role = reviewMgr.readRole( new Role( member ) );
+                roleDns.add( role.getDn() );
+            }
+
+            group.setMembers( roleDns );
+        }
+    }
+
     private void loadUserDn( User inUser ) throws SecurityException
     {
         ReviewMgr reviewMgr = ReviewMgrFactory.createInstance();

http://git-wip-us.apache.org/repos/asf/directory-fortress-core/blob/015dfdf8/src/test/java/org/apache/directory/fortress/core/GroupMgrConsole.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/directory/fortress/core/GroupMgrConsole.java b/src/test/java/org/apache/directory/fortress/core/GroupMgrConsole.java
index 13f7d2e..0ba4040 100755
--- a/src/test/java/org/apache/directory/fortress/core/GroupMgrConsole.java
+++ b/src/test/java/org/apache/directory/fortress/core/GroupMgrConsole.java
@@ -70,12 +70,24 @@ class GroupMgrConsole
             System.out.println("Enter description:");
             String desc = ReaderUtil.readLn();
             Group group = new Group( name, desc );
+
+            System.out.println("Is this a group of Users - Y or N");
+            String choice = ReaderUtil.readLn();
+            if (choice == null || choice.equalsIgnoreCase("Y"))
+            {
+                group.setType( Group.Type.USER );
+            }
+            else
+            {
+                group.setType( Group.Type.ROLE );
+            }
+
             System.out.println("Enter protocol:");
             String protocol = ReaderUtil.readLn();
             group.setProtocol( protocol );
-            System.out.println("Enter userId:");
-            String userId = ReaderUtil.readLn();
-            group.setMember( userId );
+            System.out.println("Enter member name:");
+            String mname = ReaderUtil.readLn();
+            group.setMember( mname );
             groupMgr.add( group );
             System.out.println("Group successfully added");
             System.out.println("ENTER to continue");
@@ -95,11 +107,14 @@ class GroupMgrConsole
         try
         {
             ReaderUtil.clearScreen();
+
             System.out.println("Enter group name:");
             String name = ReaderUtil.readLn();
+            Group group = new Group( name );
+
             System.out.println("Enter description:");
-            String desc = ReaderUtil.readLn();
-            Group group = new Group( name, desc );
+            group.setDescription( ReaderUtil.readLn() );
+
             System.out.println("Enter protocol:");
             String protocol = ReaderUtil.readLn();
             group.setProtocol( protocol );


Mime
View raw message