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


Java Get.setAuthorizations方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.Get.setAuthorizations方法的典型用法代码示例。如果您正苦于以下问题:Java Get.setAuthorizations方法的具体用法?Java Get.setAuthorizations怎么用?Java Get.setAuthorizations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.client.Get的用法示例。


在下文中一共展示了Get.setAuthorizations方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetForSuperUserWithFewerLabelAuths

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testGetForSuperUserWithFewerLabelAuths() throws Throwable {
  String[] auths = { SECRET };
  String user = "admin";
  VisibilityClient.setAuths(TEST_UTIL.getConnection(), auths, user);
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  final Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
      + "&!" + PRIVATE, SECRET + "&!" + PRIVATE);
  PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
    public Void run() throws Exception {
      Get g = new Get(row1);
      g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
      try (Connection connection = ConnectionFactory.createConnection(conf);
           Table t = connection.getTable(table.getName())) {
        Result result = t.get(g);
        assertTrue(!result.isEmpty());
      }
      return null;
    }
  };
  SUPERUSER.runAs(scanAction);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestVisibilityLabelsWithACL.java

示例2: testVisibilityLabelsForUserWithNoAuths

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testVisibilityLabelsForUserWithNoAuths() throws Throwable {
  String user = "admin";
  String[] auths = { SECRET };
  try (Connection conn = ConnectionFactory.createConnection(conf)) {
    VisibilityClient.clearAuths(conn, auths, user); // Removing all auths if any.
    VisibilityClient.setAuths(conn, auths, "user1");
  }
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  final Table table = createTableAndWriteDataWithLabels(tableName, SECRET);
  SecureTestUtil.grantOnTable(TEST_UTIL, NORMAL_USER1.getShortName(), tableName,
    null, null, Permission.Action.READ);
  SecureTestUtil.grantOnTable(TEST_UTIL, NORMAL_USER2.getShortName(), tableName,
    null, null, Permission.Action.READ);
  PrivilegedExceptionAction<Void> getAction = new PrivilegedExceptionAction<Void>() {
    public Void run() throws Exception {
      Get g = new Get(row1);
      g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
      try (Connection connection = ConnectionFactory.createConnection(conf);
           Table t = connection.getTable(table.getName())) {
        Result result = t.get(g);
        assertTrue(result.isEmpty());
      }
      return null;
    }
  };
  NORMAL_USER2.runAs(getAction);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestVisibilityLabelsWithACL.java

示例3: testVisibilityLabelsWithGet

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testVisibilityLabelsWithGet() throws Exception {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = createTableAndWriteDataWithLabels(tableName, SECRET + "&" + CONFIDENTIAL
      + "&!" + PRIVATE, SECRET + "&" + CONFIDENTIAL + "&" + PRIVATE)) {
    Get get = new Get(row1);
    get.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
    Result result = table.get(get);
    assertTrue(!result.isEmpty());
    Cell cell = result.getColumnLatestCell(fam, qual);
    assertTrue(Bytes.equals(value, 0, value.length, cell.getValueArray(), cell.getValueOffset(),
        cell.getValueLength()));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestVisibilityLabels.java

示例4: testVisibilityLabelsInGetThatDoesNotMatchAnyDefinedLabels

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testVisibilityLabelsInGetThatDoesNotMatchAnyDefinedLabels() throws Exception {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = createTableAndWriteDataWithLabels(tableName, "(" + SECRET + "|" + CONFIDENTIAL
      + ")", PRIVATE)) {
    Get get = new Get(row1);
    get.setAuthorizations(new Authorizations("SAMPLE"));
    Result result = table.get(get);
    assertTrue(result.isEmpty());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestVisibilityLabels.java

示例5: testLabelsWithIncrement

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testLabelsWithIncrement() throws Throwable {
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = TEST_UTIL.createTable(tableName, fam)) {
    byte[] row1 = Bytes.toBytes("row1");
    byte[] val = Bytes.toBytes(1L);
    Put put = new Put(row1);
    put.add(fam, qual, HConstants.LATEST_TIMESTAMP, val);
    put.setCellVisibility(new CellVisibility(SECRET + " & " + CONFIDENTIAL));
    table.put(put);
    Get get = new Get(row1);
    get.setAuthorizations(new Authorizations(SECRET));
    Result result = table.get(get);
    assertTrue(result.isEmpty());
    table.incrementColumnValue(row1, fam, qual, 2L);
    result = table.get(get);
    assertTrue(result.isEmpty());
    Increment increment = new Increment(row1);
    increment.addColumn(fam, qual, 2L);
    increment.setCellVisibility(new CellVisibility(SECRET));
    table.increment(increment);
    result = table.get(get);
    assertTrue(!result.isEmpty());
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:TestVisibilityLabels.java

示例6: testMutateRow

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Test
public void testMutateRow() throws Exception {
  final byte[] qual2 = Bytes.toBytes("qual2");
  TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  HTableDescriptor desc = new HTableDescriptor(tableName);
  HColumnDescriptor col = new HColumnDescriptor(fam);
  desc.addFamily(col);
  TEST_UTIL.getHBaseAdmin().createTable(desc);
  try (Table table = TEST_UTIL.getConnection().getTable(tableName)){
    Put p1 = new Put(row1);
    p1.add(fam, qual, value);
    p1.setCellVisibility(new CellVisibility(CONFIDENTIAL));

    Put p2 = new Put(row1);
    p2.add(fam, qual2, value);
    p2.setCellVisibility(new CellVisibility(SECRET));

    RowMutations rm = new RowMutations(row1);
    rm.add(p1);
    rm.add(p2);

    table.mutateRow(rm);

    Get get = new Get(row1);
    get.setAuthorizations(new Authorizations(CONFIDENTIAL));
    Result result = table.get(get);
    assertTrue(result.containsColumn(fam, qual));
    assertFalse(result.containsColumn(fam, qual2));

    get.setAuthorizations(new Authorizations(SECRET));
    result = table.get(get);
    assertFalse(result.containsColumn(fam, qual));
    assertTrue(result.containsColumn(fam, qual2));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestVisibilityLabels.java

示例7: verifyGet

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Override
protected void verifyGet(final byte[] row, final String visString, final int expected,
    final boolean nullExpected, final String... auths) throws IOException,
    InterruptedException {
  PrivilegedExceptionAction<Void> scanAction = new PrivilegedExceptionAction<Void>() {
    public Void run() throws Exception {
      try (Connection connection = ConnectionFactory.createConnection(conf1);
           Table table2 = connection.getTable(TableName.valueOf(TABLE_NAME))) {
        CellScanner cellScanner;
        Cell current;
        Get get = new Get(row);
        get.setAuthorizations(new Authorizations(auths));
        Result result = table2.get(get);
        cellScanner = result.cellScanner();
        boolean advance = cellScanner.advance();
        if (nullExpected) {
          assertTrue(!advance);
          return null;
        }
        current = cellScanner.current();
        assertArrayEquals(CellUtil.cloneRow(current), row);
        assertEquals(expected, TestCoprocessorForTagsAtSink.tags.size());
        boolean foundNonVisTag = false;
        for(Tag t : TestCoprocessorForTagsAtSink.tags) {
          if(t.getType() == NON_VIS_TAG_TYPE) {
            assertEquals(TEMP, Bytes.toString(t.getValue()));
            foundNonVisTag = true;
            break;
          }
        }
        doAssert(row, visString);
        assertTrue(foundNonVisTag);
        return null;
      }
    }
  };
  USER1.runAs(scanAction);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:TestVisibilityLabelReplicationWithExpAsString.java

示例8: getFromThrift

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
/**
 * Creates a {@link Get} (HBase) from a {@link TGet} (Thrift).
 *
 * This ignores any timestamps set on {@link TColumn} objects.
 *
 * @param in the <code>TGet</code> to convert
 *
 * @return <code>Get</code> object
 *
 * @throws IOException if an invalid time range or max version parameter is given
 */
public static Get getFromThrift(TGet in) throws IOException {
  Get out = new Get(in.getRow());

  // Timestamp overwrites time range if both are set
  if (in.isSetTimestamp()) {
    out.setTimeStamp(in.getTimestamp());
  } else if (in.isSetTimeRange()) {
    out.setTimeRange(in.getTimeRange().getMinStamp(), in.getTimeRange().getMaxStamp());
  }

  if (in.isSetMaxVersions()) {
    out.setMaxVersions(in.getMaxVersions());
  }

  if (in.isSetFilterString()) {
    ParseFilter parseFilter = new ParseFilter();
    out.setFilter(parseFilter.parseFilterString(in.getFilterString()));
  }

  if (in.isSetAttributes()) {
    addAttributes(out,in.getAttributes());
  }

  if (in.isSetAuthorizations()) {
    out.setAuthorizations(new Authorizations(in.getAuthorizations().getLabels()));
  }
  
  if (!in.isSetColumns()) {
    return out;
  }

  for (TColumn column : in.getColumns()) {
    if (column.isSetQualifier()) {
      out.addColumn(column.getFamily(), column.getQualifier());
    } else {
      out.addFamily(column.getFamily());
    }
  }

  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:53,代码来源:ThriftUtilities.java

示例9: beforeGet

import org.apache.hadoop.hbase.client.Get; //导入方法依赖的package包/类
@Override
public Get beforeGet(long rowkeyBase, Get get) {
  get.setAuthorizations(new Authorizations(
      authorizations[(int) (rowkeyBase % authorizations.length)]));
  return get;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:LoadTestDataGeneratorWithVisibilityLabels.java


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