use of org.apache.accumulo.core.security.ColumnVisibility in project accumulo by apache.
the class ConditionalComparatorTest method testComparator.
@Test
public void testComparator() {
Condition c1 = new Condition("a", "b");
Condition c2 = new Condition("a", "c");
Condition c3 = new Condition("b", "c");
Condition c4 = new Condition("a", "b").setTimestamp(5);
Condition c5 = new Condition("a", "b").setTimestamp(6);
Condition c6 = new Condition("a", "b").setVisibility(new ColumnVisibility("A&B"));
Condition c7 = new Condition("a", "b").setVisibility(new ColumnVisibility("A&C"));
ConditionComparator comparator = new ConditionComparator();
Assert.assertTrue(comparator.compare(c1, c1) == 0);
Assert.assertTrue(comparator.compare(c1, c2) < 0);
Assert.assertTrue(comparator.compare(c2, c1) > 0);
Assert.assertTrue(comparator.compare(c1, c3) < 0);
Assert.assertTrue(comparator.compare(c3, c1) > 0);
Assert.assertTrue(comparator.compare(c1, c4) < 0);
Assert.assertTrue(comparator.compare(c4, c1) > 0);
Assert.assertTrue(comparator.compare(c5, c4) < 0);
Assert.assertTrue(comparator.compare(c4, c5) > 0);
Assert.assertTrue(comparator.compare(c1, c7) < 0);
Assert.assertTrue(comparator.compare(c7, c1) > 0);
Assert.assertTrue(comparator.compare(c6, c7) < 0);
Assert.assertTrue(comparator.compare(c7, c6) > 0);
}
use of org.apache.accumulo.core.security.ColumnVisibility in project accumulo by apache.
the class TabletServerBatchDeleter method delete.
@Override
public void delete() throws MutationsRejectedException, TableNotFoundException {
BatchWriter bw = null;
try {
bw = new BatchWriterImpl(context, tableId, bwConfig);
Iterator<Entry<Key, Value>> iter = super.iterator();
while (iter.hasNext()) {
Entry<Key, Value> next = iter.next();
Key k = next.getKey();
Mutation m = new Mutation(k.getRow());
m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp());
bw.addMutation(m);
}
} finally {
if (bw != null)
bw.close();
}
}
use of org.apache.accumulo.core.security.ColumnVisibility in project accumulo by apache.
the class OfflineIterator method createIterator.
private SortedKeyValueIterator<Key, Value> createIterator(KeyExtent extent, List<String> absFiles) throws TableNotFoundException, AccumuloException, IOException {
// TODO share code w/ tablet - ACCUMULO-1303
// possible race condition here, if table is renamed
String tableName = Tables.getTableName(conn.getInstance(), tableId);
AccumuloConfiguration acuTableConf = new ConfigurationCopy(conn.tableOperations().getProperties(tableName));
Configuration conf = CachedConfiguration.getInstance();
for (SortedKeyValueIterator<Key, Value> reader : readers) {
((FileSKVIterator) reader).close();
}
readers.clear();
SamplerConfiguration scannerSamplerConfig = options.getSamplerConfiguration();
SamplerConfigurationImpl scannerSamplerConfigImpl = scannerSamplerConfig == null ? null : new SamplerConfigurationImpl(scannerSamplerConfig);
SamplerConfigurationImpl samplerConfImpl = SamplerConfigurationImpl.newSamplerConfig(acuTableConf);
if (scannerSamplerConfigImpl != null && ((samplerConfImpl != null && !scannerSamplerConfigImpl.equals(samplerConfImpl)) || samplerConfImpl == null)) {
throw new SampleNotPresentException();
}
// TODO need to close files - ACCUMULO-1303
for (String file : absFiles) {
FileSystem fs = VolumeConfiguration.getVolume(file, conf, config).getFileSystem();
FileSKVIterator reader = FileOperations.getInstance().newReaderBuilder().forFile(file, fs, conf).withTableConfiguration(acuTableConf).build();
if (scannerSamplerConfigImpl != null) {
reader = reader.getSample(scannerSamplerConfigImpl);
if (reader == null)
throw new SampleNotPresentException();
}
readers.add(reader);
}
MultiIterator multiIter = new MultiIterator(readers, extent);
OfflineIteratorEnvironment iterEnv = new OfflineIteratorEnvironment(authorizations, acuTableConf, false, samplerConfImpl == null ? null : samplerConfImpl.toSamplerConfiguration());
byte[] defaultSecurityLabel;
ColumnVisibility cv = new ColumnVisibility(acuTableConf.get(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY));
defaultSecurityLabel = cv.getExpression();
SortedKeyValueIterator<Key, Value> visFilter = IteratorUtil.setupSystemScanIterators(multiIter, new HashSet<>(options.fetchedColumns), authorizations, defaultSecurityLabel);
return iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(IteratorScope.scan, visFilter, extent, acuTableConf, options.serverSideIteratorList, options.serverSideIteratorOptions, iterEnv, false));
}
use of org.apache.accumulo.core.security.ColumnVisibility in project accumulo by apache.
the class ConditionalWriterImpl method isVisible.
private boolean isVisible(ByteSequence cv) {
Text testVis = new Text(cv.toArray());
if (testVis.getLength() == 0)
return true;
Boolean b = cache.get(testVis);
if (b != null)
return b;
try {
Boolean bb = ve.evaluate(new ColumnVisibility(testVis));
cache.put(new Text(testVis), bb);
return bb;
} catch (VisibilityParseException | BadArgumentException e) {
return false;
}
}
use of org.apache.accumulo.core.security.ColumnVisibility in project accumulo-examples by apache.
the class CountIT method setupInstance.
@Before
public void setupInstance() throws Exception {
tableName = getUniqueNames(1)[0];
conn = getConnector();
conn.tableOperations().create(tableName);
BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
ColumnVisibility cv = new ColumnVisibility();
// / has 1 dir
// /local has 2 dirs 1 file
// /local/user1 has 2 files
bw.addMutation(Ingest.buildMutation(cv, "/local", true, false, true, 272, 12345, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/user1", true, false, true, 272, 12345, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/user2", true, false, true, 272, 12345, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 12345, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 23456, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file1", false, false, false, 2024, 12345, null));
bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file2", false, false, false, 1028, 23456, null));
bw.close();
}
Aggregations