Java源码示例:org.apache.accumulo.core.security.VisibilityParseException
示例1
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
boolean result;
do {
result = super.nextKeyValue();
if (!result)
break;
// Need to create a Key from the Event
RawRecordContainerImpl e = (RawRecordContainerImpl) this.getCurrentValue();
if (null != e) {
ColumnVisibility colviz = e.getVisibility();
if (null != colviz && colviz.getParseTree() != null) {
try {
result = filter.evaluate(colviz);
} catch (VisibilityParseException e1) {
throw new IOException("Error evaluating column visibility: " + colviz, e1);
}
} else {
// Event has no column visibility, should not return it.
result = false;
}
}
} while (!result);
return result;
}
示例2
/**
* 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;
}
示例3
protected boolean accept(ColumnVisibility visibility) {
Boolean b = (Boolean) cache.get(visibility);
if (b != null)
return b;
try {
Boolean bb = ve.evaluate(visibility);
cache.put(visibility, bb);
return bb;
} catch (VisibilityParseException | BadArgumentException e) {
log.error("Parse Error", e);
return false;
}
}