org.apache.accumulo.core.security.VisibilityEvaluator Java Examples

The following examples show how to use org.apache.accumulo.core.security.VisibilityEvaluator. 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: DocumentVisibilityUtil.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if the user's authorizations allows them to have access to the
 * provided document based on its document visibility.
 * @param authorizations the {@link Authorizations}.
 * @param documentVisibility the {@link DocumentVisibility}.
 * @param doesEmptyAccessPass {@code true} if an empty authorization pass
 * allows access to everything. {@code false} otherwise.
 * @return {@code true} if the user has access to the document.
 * {@code false} otherwise.
 */
public static boolean doesUserHaveDocumentAccess(final Authorizations authorizations, final DocumentVisibility documentVisibility, final boolean doesEmptyAccessPass) {
    final Authorizations userAuths = authorizations != null ? authorizations : MongoDbRdfConstants.ALL_AUTHORIZATIONS;
    final VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(userAuths);
    boolean accept = false;
    if (doesEmptyAccessPass && MongoDbRdfConstants.ALL_AUTHORIZATIONS.equals(userAuths)) {
        accept = true;
    } else {
        try {
            accept = visibilityEvaluator.evaluate(documentVisibility);
        } catch (final VisibilityParseException e) {
            log.error("Could not parse document visibility.");
        }
    }

    return accept;
}
 
Example #2
Source File: SecureEventSequenceFileRecordReader.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
    super.initialize(split, context);
    String auths = context.getConfiguration().get(AUTHS);
    // Ensure that the authorizations were put into the configuration
    if (null == auths || auths.isEmpty())
        throw new IOException("Authorizations not specified, expected configuration property to be set: " + AUTHS);
    // Create the VisibilityFilter with no default visibility. We expect that all Events will have a column visibility set
    Authorizations a = new Authorizations(auths.split(SPLIT));
    filter = new VisibilityEvaluator(a);
}
 
Example #3
Source File: VisibilityFilter.java    From timely with Apache License 2.0 4 votes vote down vote up
public VisibilityFilter(Authorizations authorizations) {
    this.ve = new VisibilityEvaluator(authorizations);
    this.cache = new LRUMap(1000);
}
 
Example #4
Source File: VisibilityExtractor.java    From accumulo-recipes with Apache License 2.0 4 votes vote down vote up
@Override public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String> options, IteratorEnvironment env) throws IOException {
    super.init(source, options, env);
    checker = new VisibilityEvaluator(new Authorizations(options.get(AUTHS).getBytes()));
}