本文整理汇总了Java中org.apache.accumulo.core.security.Authorizations.getAuthorizations方法的典型用法代码示例。如果您正苦于以下问题:Java Authorizations.getAuthorizations方法的具体用法?Java Authorizations.getAuthorizations怎么用?Java Authorizations.getAuthorizations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.accumulo.core.security.Authorizations
的用法示例。
在下文中一共展示了Authorizations.getAuthorizations方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
private void execute(Opts opts, ScannerOpts scanOpts) throws Exception {
conn = opts.getConnector();
// add the authorizations to the user
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
auths.addAll(opts.auths.getAuthorizations());
if (!auths.isEmpty())
conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));
// create table
if (opts.createtable) {
SortedSet<Text> partitionKeys = new TreeSet<>();
for (int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++)
partitionKeys.add(new Text(new byte[] {(byte) i}));
conn.tableOperations().create(opts.getTableName());
conn.tableOperations().addSplits(opts.getTableName(), partitionKeys);
}
// send mutations
createEntries(opts);
// read entries
if (opts.readEntries) {
// Note that the user needs to have the authorizations for the specified scan authorizations
// by an administrator first
Scanner scanner = new SignedScanner(conn, opts.getTableName(), opts.auths, opts.signatureConfig, opts.signatureKeys);
scanner.setBatchSize(scanOpts.scanBatchSize);
for (Entry<Key,Value> entry : scanner)
System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
}
// delete table
if (opts.deletetable)
conn.tableOperations().delete(opts.getTableName());
}
示例2: execute
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
private void execute(Opts opts) throws Exception {
conn = opts.getConnector();
// add the authorizations to the user
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
auths.addAll(opts.auths.getAuthorizations());
if (!auths.isEmpty())
conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));
// create table
if (opts.createtable) {
SortedSet<Text> partitionKeys = new TreeSet<>();
for (int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++)
partitionKeys.add(new Text(new byte[] {(byte) i}));
conn.tableOperations().create(opts.getTableName());
conn.tableOperations().addSplits(opts.getTableName(), partitionKeys);
}
// send mutations
createEntries(opts);
// read entries
if (opts.readEntries) {
// Note that the user needs to have the authorizations for the specified scan authorizations
// by an administrator first
BatchScanner scanner = new EncryptedBatchScanner(conn, opts.getTableName(), opts.auths, 1, opts.encryptionConfig, opts.encryptionKeys);
scanner.setRanges(Collections.singletonList(new Range()));
for (Entry<Key,Value> entry : scanner)
System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
}
// delete table
if (opts.deletetable)
conn.tableOperations().delete(opts.getTableName());
}
示例3: execute
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
private void execute(Opts opts, ScannerOpts scanOpts) throws Exception {
conn = opts.getConnector();
// add the authorizations to the user
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
auths.addAll(opts.auths.getAuthorizations());
if (!auths.isEmpty())
conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));
// create table
if (opts.createtable) {
SortedSet<Text> partitionKeys = new TreeSet<>();
for (int i = Byte.MIN_VALUE; i < Byte.MAX_VALUE; i++)
partitionKeys.add(new Text(new byte[] {(byte) i}));
conn.tableOperations().create(opts.getTableName());
conn.tableOperations().addSplits(opts.getTableName(), partitionKeys);
}
// send mutations
createEntries(opts);
// read entries
if (opts.readEntries) {
// Note that the user needs to have the authorizations for the specified scan authorizations
// by an administrator first
Scanner scanner = conn.createScanner(opts.getTableName(), opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
for (Entry<Key,Value> entry : scanner)
System.out.println(entry.getKey().toString() + " -> " + entry.getValue().toString());
}
// delete table
if (opts.deletetable)
conn.tableOperations().delete(opts.getTableName());
}
示例4: getAuthorizationsStrings
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
/**
* Gets the authorizations in sorted order. The returned list is not modifiable.
* @param authorizations the {@link Authorizations}
* @return authorizations, each as a string encoded in UTF-8
*/
public static List<String> getAuthorizationsStrings(final Authorizations authorizations) {
final List<String> copy = new ArrayList<>(authorizations.getAuthorizations().size());
for (final byte[] auth : authorizations.getAuthorizations()) {
copy.add(new String(auth, Charsets.UTF_8));
}
return Collections.unmodifiableList(copy);
}
示例5: getAuths
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
private String[] getAuths(final Connector accumulo) {
Authorizations auths;
try {
auths = accumulo.securityOperations().getUserAuthorizations(accumulo.whoami());
final List<byte[]> authList = auths.getAuthorizations();
final String[] authArray = new String[authList.size()];
for(int i = 0; i < authList.size(); i++){
authArray[i] = new String(authList.get(i), "UTF-8");
}
return authArray;
} catch (AccumuloException | AccumuloSecurityException | UnsupportedEncodingException e) {
throw new RuntimeException("Cannot read authorizations for user: " + accumulo.whoami());
}
}
示例6: addUserAuths
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
/**
* Adds authorizations to a user's authorizations list.
* @param user the name of the user to add authorizations for.
* @param secOps the {@link SecurityOperations}.
* @param auths the list of authorizations to add
* @return the {@link Authorizations}.
* @throws AccumuloException
* @throws AccumuloSecurityException
*/
public static Authorizations addUserAuths(final String user, final SecurityOperations secOps, final String... auths) throws AccumuloException, AccumuloSecurityException {
final Authorizations currentUserAuths = secOps.getUserAuthorizations(user);
final List<byte[]> authList = new ArrayList<>();
for (final byte[] currentAuth : currentUserAuths.getAuthorizations()) {
authList.add(currentAuth);
}
for (final String newAuth : auths) {
authList.add(newAuth.getBytes(StandardCharsets.UTF_8));
}
final Authorizations result = new Authorizations(authList);
return result;
}
示例7: main
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
BatchWriterOpts batchOpts = new BatchWriterOpts();
opts.parseArgs(SignedConverterExample.class.getName(), args, batchOpts, scanOpts);
Connector conn = opts.getConnector();
// add the authorizations to the user
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
auths.addAll(opts.auths.getAuthorizations());
if (!auths.isEmpty())
conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));
// create table
if (opts.createDestinationTable) {
conn.tableOperations().create(opts.destination);
}
// Transform entries
Scanner scanner = conn.createScanner(opts.source, opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
BatchWriterConfig bwConfig = batchOpts.getBatchWriterConfig();
bwConfig.setDurability(opts.durability);
BatchWriter writer = new SignedBatchWriter(conn, opts.destination, bwConfig, opts.signatureConfig, opts.signatureKeys);
long count = 0;
for (Entry<Key,Value> entry : scanner) {
Mutation mutation = new Mutation(entry.getKey().getRow());
mutation.put(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier(), entry.getKey().getColumnVisibilityParsed(), entry.getKey()
.getTimestamp(), entry.getValue());
writer.addMutation(mutation);
count++;
if (count % 10000 == 0) {
System.out.println(String.format("converted %d entries", count));
}
}
writer.flush();
writer.close();
// delete table
if (opts.deleteSourceTable)
conn.tableOperations().delete(opts.source);
}
示例8: main
import org.apache.accumulo.core.security.Authorizations; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
ScannerOpts scanOpts = new ScannerOpts();
BatchWriterOpts batchOpts = new BatchWriterOpts();
opts.parseArgs(EncryptedConverterExample.class.getName(), args, batchOpts, scanOpts);
Connector conn = opts.getConnector();
// add the authorizations to the user
Authorizations userAuthorizations = conn.securityOperations().getUserAuthorizations(opts.getPrincipal());
ByteArraySet auths = new ByteArraySet(userAuthorizations.getAuthorizations());
auths.addAll(opts.auths.getAuthorizations());
if (!auths.isEmpty())
conn.securityOperations().changeUserAuthorizations(opts.getPrincipal(), new Authorizations(auths));
// create table
if (opts.createDestinationTable) {
conn.tableOperations().create(opts.destination);
}
// Transform entries
Scanner scanner = conn.createScanner(opts.source, opts.auths);
scanner.setBatchSize(scanOpts.scanBatchSize);
BatchWriterConfig bwConfig = batchOpts.getBatchWriterConfig();
bwConfig.setDurability(opts.durability);
BatchWriter writer = new EncryptedBatchWriter(conn, opts.destination, bwConfig, opts.encryptionConfig, opts.encryptionKeys);
long count = 0;
for (Entry<Key,Value> entry : scanner) {
Mutation mutation = new Mutation(entry.getKey().getRow());
mutation.put(entry.getKey().getColumnFamily(), entry.getKey().getColumnQualifier(), entry.getKey().getColumnVisibilityParsed(), entry.getKey()
.getTimestamp(), entry.getValue());
writer.addMutation(mutation);
count++;
if (count % 10000 == 0) {
System.out.println(String.format("converted %d entries", count));
}
}
writer.flush();
writer.close();
// delete table
if (opts.deleteSourceTable)
conn.tableOperations().delete(opts.source);
}