You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2015/05/08 18:32:09 UTC

[1/6] accumulo git commit: ACCUMULO-3784 fix getauths

Repository: accumulo
Updated Branches:
  refs/heads/1.6 2b168f819 -> fa22fa431
  refs/heads/1.7 61eea4243 -> 31dd5ca05
  refs/heads/master b6739a200 -> e4caf8aff


ACCUMULO-3784 fix getauths

Signed-off-by: Josh Elser <el...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/fa22fa43
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/fa22fa43
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/fa22fa43

Branch: refs/heads/1.6
Commit: fa22fa431d1de7b7f636f8011ced1b4d45bab7cd
Parents: 2b168f8
Author: Max Jordan <mj...@bbn.com>
Authored: Fri May 8 11:30:42 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 11:30:42 2015 -0400

----------------------------------------------------------------------
 .../util/shell/commands/GetAuthsCommand.java    | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
index 74aefaa..8c1e88b 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
@@ -17,8 +17,9 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -38,14 +39,20 @@ public class GetAuthsCommand extends Command {
     final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
     // 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));
-    }
+    List<String> set = sortAuthorizations(auths);
     shellState.getReader().println(StringUtils.join(set, ','));
     return 0;
   }
 
+  protected List<String> sortAuthorizations(Authorizations auths) {
+    List<String> list = new ArrayList<String>();
+    for (byte[] auth : auths) {
+      list.add(new String(auth));
+    }
+    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
+    return list;
+  }
+
   @Override
   public String description() {
     return "displays the maximum scan authorizations for a user";

http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
new file mode 100644
index 0000000..b0f0672
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.accumulo.core.util.shell.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.accumulo.core.security.Authorizations;
+import org.junit.Test;
+
+public class GetAuthsCommandTest {
+
+  @Test
+  public void removeAccumuloNamespaceTables() {
+    Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
+    GetAuthsCommand cmd = new GetAuthsCommand();
+    List<String> sorted = cmd.sortAuthorizations(auths);
+
+    assertNotNull(sorted);
+    assertEquals(sorted.size(), 4);
+
+    assertEquals(sorted.get(0), "AAA");
+    assertEquals(sorted.get(1), "aaa");
+    assertEquals(sorted.get(2), "BBB");
+    assertEquals(sorted.get(3), "bbb");
+  }
+}


[4/6] accumulo git commit: Merge branch '1.6' into 1.7

Posted by el...@apache.org.
Merge branch '1.6' into 1.7


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/31dd5ca0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/31dd5ca0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/31dd5ca0

Branch: refs/heads/master
Commit: 31dd5ca05663463d4a4a455accab9ced9ebaa63c
Parents: 61eea42 fa22fa4
Author: Josh Elser <el...@apache.org>
Authored: Fri May 8 11:55:14 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 12:31:44 2015 -0400

----------------------------------------------------------------------
 .../shell/commands/GetAuthsCommand.java         | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/31dd5ca0/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --cc shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
index c4c1b67,0000000..5c6a4eb
mode 100644,000000..100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
@@@ -1,68 -1,0 +1,75 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.shell.commands;
 +
 +import java.io.IOException;
- import java.util.SortedSet;
- import java.util.TreeSet;
++import java.util.ArrayList;
++import java.util.Collections;
++import java.util.List;
 +
 +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.shell.Shell;
 +import org.apache.accumulo.shell.Shell.Command;
 +import org.apache.accumulo.shell.ShellOptions;
 +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;
 +
 +  @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());
 +    // 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));
-     }
++    List<String> set = sortAuthorizations(auths);
 +    shellState.getReader().println(StringUtils.join(set, ','));
 +    return 0;
 +  }
 +
++  protected List<String> sortAuthorizations(Authorizations auths) {
++    List<String> list = new ArrayList<String>();
++    for (byte[] auth : auths) {
++      list.add(new String(auth));
++    }
++    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
++    return list;
++  }
++
 +  @Override
 +  public String description() {
 +    return "displays the maximum scan authorizations for a user";
 +  }
 +
 +  @Override
 +  public Options getOptions() {
 +    final Options o = new Options();
 +    userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on");
 +    userOpt.setArgName("user");
 +    o.addOption(userOpt);
 +    return o;
 +  }
 +
 +  @Override
 +  public int numArgs() {
 +    return 0;
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/31dd5ca0/shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
----------------------------------------------------------------------
diff --cc shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
index 0000000,0000000..ab57252
new file mode 100644
--- /dev/null
+++ b/shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
@@@ -1,0 -1,0 +1,44 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements.  See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache License, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License.  You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.accumulo.shell.commands;
++
++import static org.junit.Assert.assertEquals;
++import static org.junit.Assert.assertNotNull;
++
++import java.util.List;
++
++import org.apache.accumulo.core.security.Authorizations;
++import org.junit.Test;
++
++public class GetAuthsCommandTest {
++
++  @Test
++  public void removeAccumuloNamespaceTables() {
++    Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
++    GetAuthsCommand cmd = new GetAuthsCommand();
++    List<String> sorted = cmd.sortAuthorizations(auths);
++
++    assertNotNull(sorted);
++    assertEquals(sorted.size(), 4);
++
++    assertEquals(sorted.get(0), "AAA");
++    assertEquals(sorted.get(1), "aaa");
++    assertEquals(sorted.get(2), "BBB");
++    assertEquals(sorted.get(3), "bbb");
++  }
++}


[3/6] accumulo git commit: ACCUMULO-3784 fix getauths

Posted by el...@apache.org.
ACCUMULO-3784 fix getauths

Signed-off-by: Josh Elser <el...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/fa22fa43
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/fa22fa43
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/fa22fa43

Branch: refs/heads/master
Commit: fa22fa431d1de7b7f636f8011ced1b4d45bab7cd
Parents: 2b168f8
Author: Max Jordan <mj...@bbn.com>
Authored: Fri May 8 11:30:42 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 11:30:42 2015 -0400

----------------------------------------------------------------------
 .../util/shell/commands/GetAuthsCommand.java    | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
index 74aefaa..8c1e88b 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
@@ -17,8 +17,9 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -38,14 +39,20 @@ public class GetAuthsCommand extends Command {
     final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
     // 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));
-    }
+    List<String> set = sortAuthorizations(auths);
     shellState.getReader().println(StringUtils.join(set, ','));
     return 0;
   }
 
+  protected List<String> sortAuthorizations(Authorizations auths) {
+    List<String> list = new ArrayList<String>();
+    for (byte[] auth : auths) {
+      list.add(new String(auth));
+    }
+    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
+    return list;
+  }
+
   @Override
   public String description() {
     return "displays the maximum scan authorizations for a user";

http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
new file mode 100644
index 0000000..b0f0672
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.accumulo.core.util.shell.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.accumulo.core.security.Authorizations;
+import org.junit.Test;
+
+public class GetAuthsCommandTest {
+
+  @Test
+  public void removeAccumuloNamespaceTables() {
+    Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
+    GetAuthsCommand cmd = new GetAuthsCommand();
+    List<String> sorted = cmd.sortAuthorizations(auths);
+
+    assertNotNull(sorted);
+    assertEquals(sorted.size(), 4);
+
+    assertEquals(sorted.get(0), "AAA");
+    assertEquals(sorted.get(1), "aaa");
+    assertEquals(sorted.get(2), "BBB");
+    assertEquals(sorted.get(3), "bbb");
+  }
+}


[2/6] accumulo git commit: ACCUMULO-3784 fix getauths

Posted by el...@apache.org.
ACCUMULO-3784 fix getauths

Signed-off-by: Josh Elser <el...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/fa22fa43
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/fa22fa43
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/fa22fa43

Branch: refs/heads/1.7
Commit: fa22fa431d1de7b7f636f8011ced1b4d45bab7cd
Parents: 2b168f8
Author: Max Jordan <mj...@bbn.com>
Authored: Fri May 8 11:30:42 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 11:30:42 2015 -0400

----------------------------------------------------------------------
 .../util/shell/commands/GetAuthsCommand.java    | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
index 74aefaa..8c1e88b 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommand.java
@@ -17,8 +17,9 @@
 package org.apache.accumulo.core.util.shell.commands;
 
 import java.io.IOException;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -38,14 +39,20 @@ public class GetAuthsCommand extends Command {
     final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
     // 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));
-    }
+    List<String> set = sortAuthorizations(auths);
     shellState.getReader().println(StringUtils.join(set, ','));
     return 0;
   }
 
+  protected List<String> sortAuthorizations(Authorizations auths) {
+    List<String> list = new ArrayList<String>();
+    for (byte[] auth : auths) {
+      list.add(new String(auth));
+    }
+    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
+    return list;
+  }
+
   @Override
   public String description() {
     return "displays the maximum scan authorizations for a user";

http://git-wip-us.apache.org/repos/asf/accumulo/blob/fa22fa43/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
new file mode 100644
index 0000000..b0f0672
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/commands/GetAuthsCommandTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.accumulo.core.util.shell.commands;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+
+import org.apache.accumulo.core.security.Authorizations;
+import org.junit.Test;
+
+public class GetAuthsCommandTest {
+
+  @Test
+  public void removeAccumuloNamespaceTables() {
+    Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
+    GetAuthsCommand cmd = new GetAuthsCommand();
+    List<String> sorted = cmd.sortAuthorizations(auths);
+
+    assertNotNull(sorted);
+    assertEquals(sorted.size(), 4);
+
+    assertEquals(sorted.get(0), "AAA");
+    assertEquals(sorted.get(1), "aaa");
+    assertEquals(sorted.get(2), "BBB");
+    assertEquals(sorted.get(3), "bbb");
+  }
+}


[6/6] accumulo git commit: Merge branch '1.7'

Posted by el...@apache.org.
Merge branch '1.7'


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e4caf8af
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e4caf8af
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e4caf8af

Branch: refs/heads/master
Commit: e4caf8aff83dd96a31162505fbe4a0677b596466
Parents: b6739a2 31dd5ca
Author: Josh Elser <el...@apache.org>
Authored: Fri May 8 12:31:54 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 12:31:54 2015 -0400

----------------------------------------------------------------------
 .../shell/commands/GetAuthsCommand.java         | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------



[5/6] accumulo git commit: Merge branch '1.6' into 1.7

Posted by el...@apache.org.
Merge branch '1.6' into 1.7


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/31dd5ca0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/31dd5ca0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/31dd5ca0

Branch: refs/heads/1.7
Commit: 31dd5ca05663463d4a4a455accab9ced9ebaa63c
Parents: 61eea42 fa22fa4
Author: Josh Elser <el...@apache.org>
Authored: Fri May 8 11:55:14 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri May 8 12:31:44 2015 -0400

----------------------------------------------------------------------
 .../shell/commands/GetAuthsCommand.java         | 19 ++++++---
 .../shell/commands/GetAuthsCommandTest.java     | 44 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/31dd5ca0/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
----------------------------------------------------------------------
diff --cc shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
index c4c1b67,0000000..5c6a4eb
mode 100644,000000..100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/GetAuthsCommand.java
@@@ -1,68 -1,0 +1,75 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one or more
 + * contributor license agreements.  See the NOTICE file distributed with
 + * this work for additional information regarding copyright ownership.
 + * The ASF licenses this file to You under the Apache License, Version 2.0
 + * (the "License"); you may not use this file except in compliance with
 + * the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing, software
 + * distributed under the License is distributed on an "AS IS" BASIS,
 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 + * See the License for the specific language governing permissions and
 + * limitations under the License.
 + */
 +package org.apache.accumulo.shell.commands;
 +
 +import java.io.IOException;
- import java.util.SortedSet;
- import java.util.TreeSet;
++import java.util.ArrayList;
++import java.util.Collections;
++import java.util.List;
 +
 +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.shell.Shell;
 +import org.apache.accumulo.shell.Shell.Command;
 +import org.apache.accumulo.shell.ShellOptions;
 +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;
 +
 +  @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());
 +    // 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));
-     }
++    List<String> set = sortAuthorizations(auths);
 +    shellState.getReader().println(StringUtils.join(set, ','));
 +    return 0;
 +  }
 +
++  protected List<String> sortAuthorizations(Authorizations auths) {
++    List<String> list = new ArrayList<String>();
++    for (byte[] auth : auths) {
++      list.add(new String(auth));
++    }
++    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
++    return list;
++  }
++
 +  @Override
 +  public String description() {
 +    return "displays the maximum scan authorizations for a user";
 +  }
 +
 +  @Override
 +  public Options getOptions() {
 +    final Options o = new Options();
 +    userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on");
 +    userOpt.setArgName("user");
 +    o.addOption(userOpt);
 +    return o;
 +  }
 +
 +  @Override
 +  public int numArgs() {
 +    return 0;
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/31dd5ca0/shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
----------------------------------------------------------------------
diff --cc shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
index 0000000,0000000..ab57252
new file mode 100644
--- /dev/null
+++ b/shell/src/test/java/org/apache/accumulo/shell/commands/GetAuthsCommandTest.java
@@@ -1,0 -1,0 +1,44 @@@
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one or more
++ * contributor license agreements.  See the NOTICE file distributed with
++ * this work for additional information regarding copyright ownership.
++ * The ASF licenses this file to You under the Apache License, Version 2.0
++ * (the "License"); you may not use this file except in compliance with
++ * the License.  You may obtain a copy of the License at
++ *
++ *     http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.accumulo.shell.commands;
++
++import static org.junit.Assert.assertEquals;
++import static org.junit.Assert.assertNotNull;
++
++import java.util.List;
++
++import org.apache.accumulo.core.security.Authorizations;
++import org.junit.Test;
++
++public class GetAuthsCommandTest {
++
++  @Test
++  public void removeAccumuloNamespaceTables() {
++    Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
++    GetAuthsCommand cmd = new GetAuthsCommand();
++    List<String> sorted = cmd.sortAuthorizations(auths);
++
++    assertNotNull(sorted);
++    assertEquals(sorted.size(), 4);
++
++    assertEquals(sorted.get(0), "AAA");
++    assertEquals(sorted.get(1), "aaa");
++    assertEquals(sorted.get(2), "BBB");
++    assertEquals(sorted.get(3), "bbb");
++  }
++}