• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VisibilityEvaluator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.accumulo.core.security.VisibilityEvaluator的典型用法代码示例。如果您正苦于以下问题:Java VisibilityEvaluator类的具体用法?Java VisibilityEvaluator怎么用?Java VisibilityEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VisibilityEvaluator类属于org.apache.accumulo.core.security包,在下文中一共展示了VisibilityEvaluator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例4: AccumuloVisibilityFilter

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
public AccumuloVisibilityFilter(Map<String, Object> params, ESLogger logger) {
    this.logger = logger;

    if (params.get("expressionField") != null) {
        this.securityExpressionField = params.get("expressionField").toString();
    }

    String auths = params.get("auths").toString().trim();
    Authorizations authorizations;
    if (auths.isEmpty()) {
        authorizations = new Authorizations();
    } else {
        authorizations = new Authorizations(auths.split(","));
    }
    this.visibilityEvaluator = new VisibilityEvaluator(authorizations);
}
 
开发者ID:jstoneham,项目名称:elasticsearch-accumulo-security,代码行数:17,代码来源:AccumuloVisibilityFilter.java


示例5: testVersion

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
/**
 * Test that rfiles created by a specific version of PACE still work correctly.
 *
 * @param versionConfig
 *          Configuration for the version with which the rfiles were generated.
 */
private void testVersion(File versionConfig) throws Exception {
  String parentDirectory = versionConfig.getParent();

  JsonParser parser = new JsonParser();
  JsonObject configJson = parser.parse(new FileReader(versionConfig)).getAsJsonObject();

  // Get a scanner for the data file.
  List<byte[]> auths = new ArrayList<>();
  for (JsonElement authElem : configJson.getAsJsonArray("authorizations")) {
    auths.add(VisibilityEvaluator.escape(authElem.getAsString().getBytes(Utils.VISIBILITY_CHARSET), false));
  }
  Authorizations authorizations = new Authorizations(auths);

  LocalFileSystem fs = FileSystem.getLocal(new Configuration());
  Scanner dataScanner = RFile.newScanner().from(Paths.get(parentDirectory, configJson.getAsJsonPrimitive("data-table").getAsString()).toString())
      .withFileSystem(fs).withAuthorizations(authorizations).build();

  // Validate each configuration.
  for (JsonElement testElem : configJson.getAsJsonArray("tests")) {
    JsonObject test = testElem.getAsJsonObject();
    SignatureConfig signatureConfig = new SignatureConfigBuilder().readFromFile(
        new FileReader(Paths.get(parentDirectory, test.getAsJsonPrimitive("config").getAsString()).toFile())).build();
    SignatureKeyContainer keyContainer = LocalSignatureKeyContainer.read(new FileReader(Paths.get(parentDirectory,
        test.getAsJsonPrimitive("keys").getAsString()).toFile()));

    EntrySigner verifier = new EntrySigner(signatureConfig, keyContainer);
    Scanner signedScanner = RFile.newScanner().from(Paths.get(parentDirectory, test.getAsJsonPrimitive("table").getAsString()).toString()).withFileSystem(fs)
        .withAuthorizations(authorizations).build();

    runTest(dataScanner, signedScanner, verifier, signatureConfig);
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:39,代码来源:VersioningIT.java


示例6: testVersion

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
/**
 * Test that rfiles created by a specific version of PACE still work correctly.
 *
 * @param versionConfig
 *          Configuration for the version with which the rfiles were generated.
 */
private void testVersion(File versionConfig) throws Exception {
  String parentDirectory = versionConfig.getParent();

  JsonParser parser = new JsonParser();
  JsonObject configJson = parser.parse(new FileReader(versionConfig)).getAsJsonObject();

  // Get a scanner for the data file.
  List<byte[]> auths = new ArrayList<>();
  for (JsonElement authElem : configJson.getAsJsonArray("authorizations")) {
    auths.add(VisibilityEvaluator.escape(authElem.getAsString().getBytes(Utils.VISIBILITY_CHARSET), false));
  }
  Authorizations authorizations = new Authorizations(auths);

  LocalFileSystem fs = FileSystem.getLocal(new Configuration());
  Scanner dataScanner = RFile.newScanner().from(Paths.get(parentDirectory, configJson.getAsJsonPrimitive("data-table").getAsString()).toString())
      .withFileSystem(fs).withAuthorizations(authorizations).build();

  // Validate each configuration.
  for (JsonElement testElem : configJson.getAsJsonArray("tests")) {
    JsonObject test = testElem.getAsJsonObject();
    EncryptionConfig encryptionConfig = new EncryptionConfigBuilder().readFromFile(
        new FileReader(Paths.get(parentDirectory, test.getAsJsonPrimitive("config").getAsString()).toFile())).build();
    EncryptionKeyContainer keyContainer = LocalEncryptionKeyContainer.read(new FileReader(Paths.get(parentDirectory,
        test.getAsJsonPrimitive("keys").getAsString()).toFile()));

    EntryEncryptor decryptor = new EntryEncryptor(encryptionConfig, keyContainer);
    Scanner encryptedScanner = RFile.newScanner().from(Paths.get(parentDirectory, test.getAsJsonPrimitive("table").getAsString()).toString())
        .withFileSystem(fs).withAuthorizations(authorizations).build();

    runTest(dataScanner, encryptedScanner, decryptor);
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:39,代码来源:VersioningIT.java


示例7: wrapVisibility

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
/**
 * Wrap the visibility field.
 * <p>
 * The resulting field will have the value {@literal colVis = (<originalColVis>)|data}. If the original column visibility value is empty, then the deafult
 * visibility value will be used in place of originalColVis.
 *
 * @param visibility
 *          The visibility data being wrapped.
 * @param data
 *          data to wrap into visibility.
 * @return Wrapped visibility.
 */
private static byte[] wrapVisibility(byte[] visibility, byte[] data) throws IOException {
  ByteArrayOutputStream colVisStream = new ByteArrayOutputStream();
  DataOutput colVisOut = new DataOutputStream(colVisStream);

  colVisOut.writeByte((byte) '(');
  colVisOut.write(visibility);
  colVisOut.writeByte((byte) ')');
  colVisOut.writeByte((byte) '|');
  colVisOut.write(VisibilityEvaluator.escape(data, true));

  return colVisStream.toByteArray();
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:25,代码来源:EntrySigner.java


示例8: VisibilityIterator

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
public VisibilityIterator(final List<T> values, Authorizations authorizations) {
	this.values = values;
	this.ve = new VisibilityEvaluator(authorizations);
	this.expectedItems = values.size();
}
 
开发者ID:Sotera,项目名称:zephyr-contrib,代码行数:6,代码来源:VisibilityIterator.java


示例9: init

import org.apache.accumulo.core.security.VisibilityEvaluator; //导入依赖的package包/类
@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()));
}
 
开发者ID:calrissian,项目名称:accumulo-recipes,代码行数:5,代码来源:VisibilityExtractor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZKRMStateStore类代码示例发布时间:2022-05-23
下一篇:
Java KeepDeletedCells类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap