本文整理汇总了Java中org.apache.accumulo.core.security.VisibilityEvaluator.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java VisibilityEvaluator.evaluate方法的具体用法?Java VisibilityEvaluator.evaluate怎么用?Java VisibilityEvaluator.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.security.VisibilityEvaluator
的用法示例。
在下文中一共展示了VisibilityEvaluator.evaluate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canRead
import org.apache.accumulo.core.security.VisibilityEvaluator; //导入方法依赖的package包/类
@Override
public boolean canRead(Visibility visibility) {
Preconditions.checkNotNull(visibility, "visibility is required");
// this is just a shortcut so that we don't need to construct evaluators and visibility objects to check for an empty string.
if (visibility.getVisibilityString().length() == 0) {
return true;
}
VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(new org.apache.accumulo.core.security.Authorizations(this.getAuthorizations()));
ColumnVisibility columnVisibility = new ColumnVisibility(visibility.getVisibilityString());
try {
return visibilityEvaluator.evaluate(columnVisibility);
} catch (VisibilityParseException e) {
throw new VertexiumException("could not evaluate visibility " + visibility.getVisibilityString(), e);
}
}
示例2: doesUserHaveDocumentAccess
import org.apache.accumulo.core.security.VisibilityEvaluator; //导入方法依赖的package包/类
/**
* 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: validateVisibilityExpression
import org.apache.accumulo.core.security.VisibilityEvaluator; //导入方法依赖的package包/类
/**
* Validate Accumulo-style visibility expression against a set of authorizations.
*
* @param auths Formal authorizations of the user
* @param visibilityExpression Accumulo-style visibility expression
* @return true if validation authorizations against visibility expression, false otherwise
*/
public static boolean validateVisibilityExpression(Set<String> auths, String visibilityExpression) {
if (StringUtils.isBlank(visibilityExpression)) {
return true; // No visibility to check
}
if (auths == null || auths.isEmpty()) {
return false; // Has visibility but no auths
}
final VisibilityEvaluator visEval = new VisibilityEvaluator(
new org.apache.accumulo.core.security.Authorizations(
auths.toArray(new String[] {})));
try {
return visEval.evaluate(new ColumnVisibility(visibilityExpression));
} catch (final VisibilityParseException e) {
return false;
}
}