当前位置: 首页>>代码示例>>Java>>正文


Java VisibilityEvaluator.evaluate方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:18,代码来源:AccumuloAuthorizations.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:DocumentVisibilityUtil.java

示例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;
    }
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:27,代码来源:PermissionUtils.java


注:本文中的org.apache.accumulo.core.security.VisibilityEvaluator.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。