You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/03/20 15:12:33 UTC
svn commit: r1458842 - in /accumulo/trunk/core/src:
main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
test/java/org/apache/accumulo/core/util/shell/ShellTest.java
Author: ecn
Date: Wed Mar 20 14:12:33 2013
New Revision: 1458842
URL: http://svn.apache.org/r1458842
Log:
ACCUMULO-1066 applying patch to display auths in sorted order
Modified:
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java?rev=1458842&r1=1458841&r2=1458842&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java Wed Mar 20 14:12:33 2013
@@ -17,14 +17,18 @@
package org.apache.accumulo.core.util.shell.commands;
import java.io.IOException;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.util.shell.Shell;
import org.apache.accumulo.core.util.shell.Shell.Command;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
+import org.apache.commons.lang.StringUtils;
public class GetAuthsCommand extends Command {
private Option userOpt;
@@ -32,7 +36,13 @@ public class GetAuthsCommand extends Com
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException {
final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
- shellState.getReader().printString(shellState.getConnector().securityOperations().getUserAuthorizations(user) + "\n");
+ // Sort authorizations
+ Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
+ SortedSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ for (byte[] auth : auths) {
+ set.add(new String(auth));
+ }
+ shellState.getReader().printString(StringUtils.join(set, ',') + "\n");
return 0;
}
Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1458842&r1=1458841&r2=1458842&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java (original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java Wed Mar 20 14:12:33 2013
@@ -149,13 +149,13 @@ public class ShellTest {
Shell.log.debug("Starting auths test --------------------------");
exec("setauths x,y,z", false, "Missing required option");
exec("setauths -s x,y,z -u notauser", false, "user does not exist");
- exec("setauths -s x,y,z", true);
+ exec("setauths -s y,z,x", true);
exec("getauths -u notauser", false,"user does not exist");
- exec("getauths", true,"y,z,x");
+ exec("getauths", true,"x,y,z");
exec("addauths -u notauser", false,"Missing required option");
exec("addauths -u notauser -s foo", false,"user does not exist");
exec("addauths -s a", true);
- exec("getauths", true, "y,z,a,x");
+ exec("getauths", true, "a,x,y,z");
exec("setauths -c", true);
}