org.apache.accumulo.core.client.Connector.securityOperations()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.apache.accumulo.core.client.Connector.securityOperations()方法的一些代码示例,展示了Connector.securityOperations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector.securityOperations()方法的具体详情如下:
包路径:org.apache.accumulo.core.client.Connector
类名称:Connector
方法名:securityOperations

Connector.securityOperations介绍

[英]Retrieves a SecurityOperations object to perform user security operations, such as creating users.
[中]检索SecurityOperations对象以执行用户安全操作,例如创建用户。

代码示例

代码示例来源:origin: prestodb/presto

@Inject
public AccumuloClient(
    Connector connector,
    AccumuloConfig config,
    ZooKeeperMetadataManager metaManager,
    AccumuloTableManager tableManager,
    IndexLookup indexLookup)
    throws AccumuloException, AccumuloSecurityException
{
  this.connector = requireNonNull(connector, "connector is null");
  this.username = requireNonNull(config, "config is null").getUsername();
  this.metaManager = requireNonNull(metaManager, "metaManager is null");
  this.tableManager = requireNonNull(tableManager, "tableManager is null");
  this.indexLookup = requireNonNull(indexLookup, "indexLookup is null");
  this.auths = connector.securityOperations().getUserAuthorizations(username);
}

代码示例来源:origin: prestodb/presto

Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
LOG.debug("Using session scanner auths for user %s: %s", sessionScanUser, scanAuths);
return scanAuths;
Authorizations auths = connector.securityOperations().getUserAuthorizations(username);
LOG.debug("scan_auths table property not set, using user auths: %s", auths);
return auths;

代码示例来源:origin: prestodb/presto

private Optional<String> getDefaultTabletLocation(String fulltable)
{
  try {
    String tableId = connector.tableOperations().tableIdMap().get(fulltable);
    // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row
    Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username));
    scan.fetchColumnFamily(new Text("loc"));
    scan.setRange(new Range(tableId + '<'));
    // scan the entry
    Optional<String> location = Optional.empty();
    for (Entry<Key, Value> entry : scan) {
      if (location.isPresent()) {
        throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry");
      }
      location = Optional.of(entry.getValue().toString());
    }
    scan.close();
    return location;
  }
  catch (Exception e) {
    // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet.
    // This is purely an optimization, but we will want to log the error.
    LOG.error("Failed to get tablet location, returning dummy location", e);
    return Optional.empty();
  }
}

代码示例来源:origin: prestodb/presto

new Indexer(
    connector,
    connector.securityOperations().getUserAuthorizations(username),
    table,
    conf));

代码示例来源:origin: prestodb/presto

Authorizations scanAuths = connector.securityOperations().getUserAuthorizations(sessionScanUser);
LOG.debug("Using session scan auths for user %s: %s", sessionScanUser, scanAuths);
return scanAuths;

代码示例来源:origin: uk.gov.gchq.gaffer/spark-accumulo-library

private boolean checkAccess(final Connector connector, final String user, final String table) {
  try {
    if (!connector.securityOperations().hasTablePermission(user, table, TablePermission.READ)
        && !connector.securityOperations().hasNamespacePermission(user, table, NamespacePermission.READ)) {
      return false;
    }
  } catch (final AccumuloException | AccumuloSecurityException e) {
    return false;
  }
  return true;
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private void verifyHasNoTablePermissions(Connector root_conn, String user, String table,
   TablePermission... perms) throws AccumuloException, AccumuloSecurityException {
  for (TablePermission p : perms)
   if (root_conn.securityOperations().hasTablePermission(user, table, p))
    throw new IllegalStateException(
      user + " SHOULD NOT have table permission " + p + " for table " + table);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

private void grantEverySystemPriv(Connector conn, String user)
  throws AccumuloSecurityException, AccumuloException {
 SystemPermission[] arrayOfP = new SystemPermission[] {SystemPermission.SYSTEM,
   SystemPermission.ALTER_TABLE, SystemPermission.ALTER_USER, SystemPermission.CREATE_TABLE,
   SystemPermission.CREATE_USER, SystemPermission.DROP_TABLE, SystemPermission.DROP_USER};
 for (SystemPermission p : arrayOfP) {
  conn.securityOperations().grantSystemPermission(user, p);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-proxy

@Override
public void dropLocalUser(ByteBuffer login, String user)
  throws org.apache.accumulo.proxy.thrift.AccumuloException,
  org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 try {
  getConnector(login).securityOperations().dropLocalUser(user);
 } catch (Exception e) {
  handleException(e);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-shell

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
  throws AccumuloException, AccumuloSecurityException, IOException {
 final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
 // Sort authorizations
 Authorizations auths = shellState.getConnector().securityOperations()
   .getUserAuthorizations(user);
 List<String> set = sortAuthorizations(auths);
 shellState.getReader().println(StringUtils.join(set, ','));
 return 0;
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Before
public void setupInstance() throws Exception {
 conn = getConnector();
 ReplicationTable.setOnline(conn);
 conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME,
   TablePermission.WRITE);
 conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME,
   TablePermission.READ);
 fs = EasyMock.mock(VolumeManager.class);
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@After
public void resetAuths() throws Exception {
 Connector c = getConnector();
 if (null != origAuths) {
  c.securityOperations().changeUserAuthorizations(getAdminPrincipal(), origAuths);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Before
public void initialize() throws Exception {
 conn = getConnector();
 rcrr = new MockRemoveCompleteReplicationRecords(conn);
 conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME,
   TablePermission.READ);
 conn.securityOperations().grantTablePermission(conn.whoami(), ReplicationTable.NAME,
   TablePermission.WRITE);
 ReplicationTable.setOnline(conn);
}

代码示例来源:origin: org.apache.accumulo/accumulo-proxy

@Override
public void createLocalUser(ByteBuffer login, String user, ByteBuffer password)
  throws org.apache.accumulo.proxy.thrift.AccumuloException,
  org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 try {
  getConnector(login).securityOperations().createLocalUser(user, new PasswordToken(password));
 } catch (Exception e) {
  handleException(e);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-proxy

@Override
public List<ByteBuffer> getUserAuthorizations(ByteBuffer login, String user)
  throws org.apache.accumulo.proxy.thrift.AccumuloException,
  org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 try {
  return getConnector(login).securityOperations().getUserAuthorizations(user)
    .getAuthorizationsBB();
 } catch (Exception e) {
  handleException(e);
  return null;
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Override
 public Void run() throws Exception {
  // As the "root" user, open up the connection and get a delegation token
  Connector conn = mac.getConnector(qualifiedNewUser, new KerberosToken());
  log.info("Created connector as {}", qualifiedNewUser);
  assertEquals(qualifiedNewUser, conn.whoami());
  conn.securityOperations().getDelegationToken(new DelegationTokenConfig());
  return null;
 }
});

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Before
public void setupInstance() throws Exception {
 conn = getConnector();
 tableName = getUniqueNames(1)[0];
 conn.securityOperations().changeUserAuthorizations(conn.whoami(), AUTHS);
}

代码示例来源:origin: org.apache.accumulo/accumulo-proxy

@Override
public void grantSystemPermission(ByteBuffer login, String user,
  org.apache.accumulo.proxy.thrift.SystemPermission perm)
  throws org.apache.accumulo.proxy.thrift.AccumuloException,
  org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
 try {
  getConnector(login).securityOperations().grantSystemPermission(user,
    SystemPermission.getPermissionById((byte) perm.getValue()));
 } catch (Exception e) {
  handleException(e);
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Override
 public AuthenticationToken run() throws Exception {
  Connector conn = mac.getConnector(rootUser.getPrincipal(), new KerberosToken());
  log.info("Created connector as {}", rootUser.getPrincipal());
  assertEquals(rootUser.getPrincipal(), conn.whoami());
  // Should fail
  return conn.securityOperations().getDelegationToken(
    new DelegationTokenConfig().setTokenLifetime(Long.MAX_VALUE, TimeUnit.MILLISECONDS));
 }
});

代码示例来源:origin: org.apache.accumulo/accumulo-test

@Override
 public AuthenticationToken run() throws Exception {
  Connector conn = mac.getConnector(rootUser.getPrincipal(), new KerberosToken());
  log.info("Created connector as {}", rootUser.getPrincipal());
  assertEquals(rootUser.getPrincipal(), conn.whoami());
  AuthenticationToken token = conn.securityOperations()
    .getDelegationToken(new DelegationTokenConfig());
  assertTrue("Could not get tables with delegation token", mac
    .getConnector(rootUser.getPrincipal(), token).tableOperations().list().size() > 0);
  return token;
 }
});

相关文章