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/01/14 21:20:13 UTC
svn commit: r1433099 -
/accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
Author: ecn
Date: Mon Jan 14 20:20:13 2013
New Revision: 1433099
URL: http://svn.apache.org/viewvc?rev=1433099&view=rev
Log:
ACCUMULO-282 add in user authorizations so the simple example works simply
Modified:
accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
Modified: accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java?rev=1433099&r1=1433098&r2=1433099&view=diff
==============================================================================
--- accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java (original)
+++ accumulo/trunk/examples/simple/src/main/java/org/apache/accumulo/examples/simple/client/ReadWriteExample.java Mon Jan 14 20:20:13 2013
@@ -16,7 +16,13 @@
*/
package org.apache.accumulo.examples.simple.client;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -31,6 +37,7 @@ import org.apache.accumulo.core.data.Mut
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.security.ColumnVisibility;
+import org.apache.accumulo.core.util.ByteArraySet;
import org.apache.hadoop.io.Text;
import com.beust.jcommander.Parameter;
@@ -65,6 +72,14 @@ public class ReadWriteExample {
private void execute(Opts opts, ScannerOpts scanOpts) throws Exception {
conn = opts.getConnector();
+
+ // add the authorizations to the user
+ Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.user);
+ ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
+ auths.addAll(opts.auths.getAuthorizations());
+ if (!auths.isEmpty())
+ conn.securityOperations().changeUserAuthorizations(opts.user, new Authorizations(auths));
+
// create table
if (opts.createtable) {
SortedSet<Text> partitionKeys = new TreeSet<Text>();