Java Code Examples for org.apache.accumulo.core.security.ColumnVisibility#getExpression()

The following examples show how to use org.apache.accumulo.core.security.ColumnVisibility#getExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecordIterator.java    From datawave with Apache License 2.0 6 votes vote down vote up
/**
 * Applies the table configuration if one is specified.
 * 
 * @param topIter
 * @param conf
 * @return
 * @throws IOException
 */
protected SortedKeyValueIterator<Key,Value> applyTableIterators(SortedKeyValueIterator<Key,Value> topIter, Configuration conf) throws IOException {
    
    if (null != acuTableConf) {
        // don't need to be populated as we'll do this later.
        RFileEnvironment iterEnv = new RFileEnvironment();
        
        List<IterInfo> serverSideIteratorList = Collections.emptyList();
        Map<String,Map<String,String>> serverSideIteratorOptions = Collections.emptyMap();
        
        byte[] defaultSecurityLabel;
        
        ColumnVisibility cv = new ColumnVisibility(acuTableConf.get(Property.TABLE_DEFAULT_SCANTIME_VISIBILITY));
        defaultSecurityLabel = cv.getExpression();
        
        SortedKeyValueIterator<Key,Value> visFilter = VisibilityFilter.wrap(topIter, auths, defaultSecurityLabel);
        
        return IteratorUtil.loadIterators(IteratorScope.scan, visFilter, null, acuTableConf, serverSideIteratorList, serverSideIteratorOptions, iterEnv,
                        false);
    }
    
    return topIter;
}
 
Example 2
Source File: Indexer.java    From presto with Apache License 2.0 5 votes vote down vote up
public MetricsKey(ByteBuffer row, ByteBuffer family, ColumnVisibility visibility)
{
    requireNonNull(row, "row is null");
    requireNonNull(family, "family is null");
    requireNonNull(visibility, "visibility is null");
    this.row = row;
    this.family = family;
    this.visibility = visibility.getExpression() != null ? visibility : EMPTY_VISIBILITY;
}
 
Example 3
Source File: FieldIndexCountingIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Row : shardId Fam : fieldName Qual: fieldValue \x00 datatype
 * 
 * @return our new top key with the aggregated columnVisibility
 */
private Key buildReturnKey() {
    if (log.isTraceEnabled()) {
        log.trace("buildReturnKey, currentRow: " + this.currentRow);
        log.trace("buildReturnKey, currentFieldName: " + this.currentFieldName);
        log.trace("buildReturnKey, currentFieldValue: " + this.currentFieldValue);
    }
    
    Text cq = new Text(this.currentFieldValue);
    if (this.uniqByDataTypeOption) {
        TextUtil.textAppend(cq, this.currentDataType);
    }
    
    // Combine the column visibilities into a single one
    // NOTE: key.getColumnVisibility actually returns a Text object so we need to convert them
    Set<ColumnVisibility> columnVisibilities = new HashSet<>();
    for (Text t : this.visibilitySet) {
        columnVisibilities.add(new ColumnVisibility(t));
    }
    ColumnVisibility cv;
    try {
        cv = markingFunctions.combine(columnVisibilities);
    } catch (MarkingFunctions.Exception e) {
        log.error("Could not combine visibilities: " + visibilitySet + "  " + e);
        return null;
    }
    
    return new Key(this.currentRow, new Text(this.currentFieldName), cq, new Text(cv.getExpression()), this.maxTimeStamp);
}
 
Example 4
Source File: GlobalIndexDateSummaryIterator.java    From datawave with Apache License 2.0 5 votes vote down vote up
public Map<Key,Value> getKeyValues() throws IOException {
    Map<Key,Value> resultsMap = new HashMap<>();
    for (Entry<String,MutableLong> entry : summary.entrySet()) {
        // Key: row = fieldName, colf = datatype, colq = date
        // Value: count
        String datatype = entry.getKey();
        long count = entry.getValue().longValue();
        
        try {
            // Calculate the ColumnVisibility for this key from the combiner.
            Set<ColumnVisibility> columnVisibilities = this.columnVisibilitiesMap.get(datatype);
            
            // Note that the access controls found in the combined ColumnVisibility will be pulled out appropriately here
            ColumnVisibility cv = markingFunctions.combine(columnVisibilities);
            
            // Create a new Key compatible with the shardIndex key format
            Key k = new Key(this.fieldValue, this.fieldName, this.date + '\0' + datatype, new String(cv.getExpression()));
            
            // Create a UID object with just the count for the Value
            Builder uidBuilder = Uid.List.newBuilder();
            uidBuilder.setIGNORE(false);
            uidBuilder.setCOUNT(count);
            Uid.List uidList = uidBuilder.build();
            org.apache.accumulo.core.data.Value v = new org.apache.accumulo.core.data.Value(uidList.toByteArray());
            resultsMap.put(k, v);
        } catch (Exception e) {
            // We want to stop the scan when we cannot properly combine ColumnVisibility
            String message = "Could not create combined ColumnVisibility";
            log.error(message, e);
            throw new IOException(message, e);
        }
    }
    return resultsMap;
}
 
Example 5
Source File: EdgeKey.java    From datawave with Apache License 2.0 4 votes vote down vote up
public EdgeKeyBuilder setColvis(ColumnVisibility colvis) {
    this.colvis = new Text(colvis.getExpression());
    return this;
}
 
Example 6
Source File: FieldCardinalityBase.java    From datawave with Apache License 2.0 4 votes vote down vote up
public void setColumnVisibility(ColumnVisibility columnVisibility) {
    String cvString = (columnVisibility == null) ? null : new String(columnVisibility.getExpression(), Charsets.UTF_8);
    setColumnVisibility(cvString);
}
 
Example 7
Source File: FieldBase.java    From datawave with Apache License 2.0 4 votes vote down vote up
public void setColumnVisibility(ColumnVisibility columnVisibility) {
    String cvString = (columnVisibility == null) ? null : new String(columnVisibility.getExpression(), Charsets.UTF_8);
    setColumnVisibility(cvString);
}
 
Example 8
Source File: MergeToolMapper.java    From rya with Apache License 2.0 4 votes vote down vote up
private static RyaStatement updateRyaStatementColumnVisibility(final RyaStatement ryaStatement, final ColumnVisibility newCv) {
    final RyaStatement newCvRyaStatement = new RyaStatement(ryaStatement.getSubject(), ryaStatement.getPredicate(), ryaStatement.getObject(), ryaStatement.getContext(), ryaStatement.getQualifer(), newCv.getExpression(), ryaStatement.getValue(), ryaStatement.getTimestamp());
    return newCvRyaStatement;
}
 
Example 9
Source File: VisibilityCache.java    From fluo with Apache License 2.0 4 votes vote down vote up
@Override
public int weigh(Bytes key, ColumnVisibility vis) {
  return key.length() + vis.getExpression().length + 32;
}