incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1196044 - /incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java
Date Tue, 01 Nov 2011 15:12:29 GMT
Author: ecn
Date: Tue Nov  1 15:12:29 2011
New Revision: 1196044

URL: http://svn.apache.org/viewvc?rev=1196044&view=rev
Log:
ACCUMULO-86: fix example to set visibilities to prevent unexpected permission issues

Modified:
    incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java

Modified: incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java?rev=1196044&r1=1196043&r2=1196044&view=diff
==============================================================================
--- incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java
(original)
+++ incubator/accumulo/branches/1.3/src/examples/src/main/java/org/apache/accumulo/examples/dirlist/Ingest.java
Tue Nov  1 15:12:29 2011
@@ -18,6 +18,8 @@ package org.apache.accumulo.examples.dir
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.Connector;
@@ -25,6 +27,7 @@ import org.apache.accumulo.core.client.Z
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.iterators.aggregation.LongSummation;
+import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.hadoop.io.Text;
 
@@ -92,6 +95,7 @@ public class Ingest {
     String pass = args[3];
     String table = args[4];
     String indexTable = args[5];
+    byte[] visibility = args[6].getBytes();
     ColumnVisibility colvis = new ColumnVisibility(args[6]);
     
     Connector conn = new ZooKeeperInstance(instance, zooKeepers).getConnector(user, pass.getBytes());
@@ -99,6 +103,17 @@ public class Ingest {
       conn.tableOperations().create(table);
     if (!conn.tableOperations().exists(indexTable))
       conn.tableOperations().create(indexTable);
+      Authorizations auths = conn.securityOperations().getUserAuthorizations(user);
+      if (!auths.contains(visibility)) {
+        List<byte[]> copy = new ArrayList<byte[]>(auths.getAuthorizations());
+        copy.add(visibility);
+        try {
+          conn.securityOperations().changeUserAuthorizations(user, new Authorizations(copy));
+      } catch (Exception ex) {
+        System.out.println("Unable to add visiblity to user " + user + ": " + ex);
+        System.exit(1);
+      }
+    }
     BatchWriter mainBW = conn.createBatchWriter(table, 50000000, 300000l, 4);
     BatchWriter indexBW = conn.createBatchWriter(indexTable, 50000000, 300000l, 4);
     for (int i = 7; i < args.length; i++) {



Mime
View raw message