Author: jbonofre
Date: Thu Oct 3 08:48:30 2013
New Revision: 1528749
URL: http://svn.apache.org/r1528749
Log:
[KARAF-2434] Fix the JAAS ListUsersCommand and include the group role
add/delete commands
Modified:
karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/ListUsersCommand.java
karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml
Modified:
karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/ListUsersCommand.java
URL:
http://svn.apache.org/viewvc/karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/ListUsersCommand.java?rev=1528749&r1=1528748&r2=1528749&view=diff
==============================================================================
---
karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/ListUsersCommand.java
(original)
+++
karaf/trunk/jaas/command/src/main/java/org/apache/karaf/jaas/command/ListUsersCommand.java
Thu Oct 3 08:48:30 2013
@@ -24,7 +24,6 @@ import org.apache.karaf.jaas.modules.Bac
import org.apache.karaf.shell.table.ShellTable;
import javax.security.auth.login.AppConfigurationEntry;
-import java.security.Principal;
import java.util.ArrayList;
import java.util.List;
@@ -65,8 +64,16 @@ public class ListUsersCommand extends Ja
String userName = user.getName();
for (GroupPrincipal group : engine.listGroups(user)) {
- String groupName = group.getName();
- reportedRoles.addAll(displayRole(engine, userName, groupName,
group, table));
+ reportedRoles.addAll(displayGroupRoles(engine, userName,
group, table));
+ }
+
+ for (RolePrincipal role : engine.listRoles(user)) {
+ String roleName = role.getName();
+ if (reportedRoles.contains(roleName)) {
+ continue;
+ }
+ reportedRoles.add(roleName);
+ table.addRow().addContent(userName, "", roleName);
}
if (reportedRoles.size() == 0) {
@@ -80,18 +87,17 @@ public class ListUsersCommand extends Ja
return null;
}
- private List<String> displayRole(BackingEngine engine, String userName,
String groupName, Principal principal, ShellTable table) {
+ private List<String> displayGroupRoles(BackingEngine engine, String
userName, GroupPrincipal group, ShellTable table) {
List<String> names = new ArrayList<String>();
- List<RolePrincipal> roles = engine.listRoles(principal);
+ List<RolePrincipal> roles = engine.listRoles(group);
if (roles != null && roles.size() >= 1) {
for (RolePrincipal role : roles) {
String roleName = role.getName();
names.add(roleName);
- table.addRow().addContent(userName, groupName, roleName);
+ table.addRow().addContent(userName, group.getName(), roleName);
}
}
-
return names;
}
Modified:
karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml
URL:
http://svn.apache.org/viewvc/karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml?rev=1528749&r1=1528748&r2=1528749&view=diff
==============================================================================
---
karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml
(original)
+++
karaf/trunk/jaas/command/src/main/resources/OSGI-INF/blueprint/jaas-command.xml
Thu Oct 3 08:48:30 2013
@@ -69,6 +69,12 @@
<command>
<action class="org.apache.karaf.jaas.command.GroupDeleteCommand"/>
</command>
+ <command>
+ <action class="org.apache.karaf.jaas.command.GroupRoleAddCommand"/>
+ </command>
+ <command>
+ <action
class="org.apache.karaf.jaas.command.GroupRoleDeleteCommand"/>
+ </command>
</command-bundle>
<!-- JAAS Realms -->