热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.accumulo.core.security.Authorizations.getAuthorizations()方法的使用及代码示例

本文整理了Java中org.apache.accumulo.core.security.Authorizations.getAuthorizations()方法的一些代

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

Authorizations.getAuthorizations介绍

[英]Gets the authorizations in sorted order. The returned list is not modifiable.
[中]按排序顺序获取授权。返回的列表不可修改。

代码示例

代码示例来源:origin: apache/accumulo

@Override
public Iterator iterator() {
return getAuthorizations().iterator();
}

代码示例来源:origin: apache/accumulo

/**
* Creates a new {@link Authorizations} object with escaped forms of the authorizations in the
* given object.
*
* @param auths
* original authorizations
* @return authorizations object with escaped authorization strings
* @see #escape(byte[], boolean)
*/
static Authorizations escape(Authorizations auths) {
ArrayList retAuths = new ArrayList<>(auths.getAuthorizations().size());
for (byte[] auth : auths.getAuthorizations())
retAuths.add(escape(auth, false));
return new Authorizations(retAuths);
}

代码示例来源:origin: apache/accumulo

@Override
public void changeUserAuthorizations(final String principal, final Authorizations authorizations)
throws AccumuloException, AccumuloSecurityException {
checkArgument(principal != null, "principal is null");
checkArgument(authorizations != null, "authorizations is null");
executeVoid(client -> client.changeAuthorizations(Tracer.traceInfo(), context.rpcCreds(),
principal, ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations())));
}

代码示例来源:origin: apache/accumulo

ByteBufferUtil.toByteBuffers(auths.getAuthorizations()), tableId.canonicalID(),
DurabilityImpl.toThrift(durability), this.classLoaderContext);

代码示例来源:origin: apache/accumulo

thriftTabletRanges, Translator.translate(columns, Translators.CT),
options.serverSideIteratorList, options.serverSideIteratorOptions,
ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()), waitForWrites,
SamplerConfigurationImpl.toThrift(options.getSamplerConfiguration()),
options.batchTimeOut, options.classLoaderContext, execHints);

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

@Override
public Iterator iterator() {
return getAuthorizations().iterator();
}

代码示例来源:origin: apache/incubator-rya

/**
* 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 getAuthorizationsStrings(final Authorizations authorizations) {
final List copy = new ArrayList<>(authorizations.getAuthorizations().size());
for (final byte[] auth : authorizations.getAuthorizations()) {
copy.add(new String(auth, Charsets.UTF_8));
}
return Collections.unmodifiableList(copy);
}
}

代码示例来源:origin: org.apache.rya/mongodb.rya

/**
* 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 getAuthorizationsStrings(final Authorizations authorizations) {
final List copy = new ArrayList<>(authorizations.getAuthorizations().size());
for (final byte[] auth : authorizations.getAuthorizations()) {
copy.add(new String(auth, Charsets.UTF_8));
}
return Collections.unmodifiableList(copy);
}
}

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

/**
* Creates a new {@link Authorizations} object with escaped forms of the authorizations in the
* given object.
*
* @param auths
* original authorizations
* @return authorizations object with escaped authorization strings
* @see #escape(byte[], boolean)
*/
static Authorizations escape(Authorizations auths) {
ArrayList retAuths = new ArrayList<>(auths.getAuthorizations().size());
for (byte[] auth : auths.getAuthorizations())
retAuths.add(escape(auth, false));
return new Authorizations(retAuths);
}

代码示例来源:origin: apache/incubator-rya

/**
* 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 {@link Authorizations} to add
* @return the {@link Authorizations}.
* @throws AccumuloException
* @throws AccumuloSecurityException
*/
public static Authorizations addUserAuths(final String user, final SecurityOperations secOps, final Authorizations auths) throws AccumuloException, AccumuloSecurityException {
final List authList = new ArrayList<>();
for (final byte[] authBytes : auths.getAuthorizations()) {
final String auth = new String(authBytes, StandardCharsets.UTF_8);
authList.add(auth);
}
return addUserAuths(user, secOps, authList.toArray(new String[0]));
}

代码示例来源:origin: org.apache.rya/rya.export.accumulo

/**
* 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 {@link Authorizations} to add
* @return the {@link Authorizations}.
* @throws AccumuloException
* @throws AccumuloSecurityException
*/
public static Authorizations addUserAuths(final String user, final SecurityOperations secOps, final Authorizations auths) throws AccumuloException, AccumuloSecurityException {
final List authList = new ArrayList<>();
for (final byte[] authBytes : auths.getAuthorizations()) {
final String auth = new String(authBytes, StandardCharsets.UTF_8);
authList.add(auth);
}
return addUserAuths(user, secOps, authList.toArray(new String[0]));
}

代码示例来源:origin: apache/incubator-rya

/**
* 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 {@link Authorizations} to add
* @return the {@link Authorizations}.
* @throws AccumuloException
* @throws AccumuloSecurityException
*/
public static Authorizations addUserAuths(final String user, final SecurityOperations secOps, final Authorizations auths) throws AccumuloException, AccumuloSecurityException {
final List authList = new ArrayList<>();
for (final byte[] authBytes : auths.getAuthorizations()) {
final String auth = new String(authBytes, StandardCharsets.UTF_8);
authList.add(auth);
}
return addUserAuths(user, secOps, authList.toArray(new String[0]));
}

代码示例来源:origin: org.apache.rya/rya.export.accumulo

/**
* 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 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;
}

代码示例来源:origin: apache/incubator-rya

/**
* 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 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;
}

代码示例来源:origin: apache/incubator-rya

/**
* 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 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;
}

代码示例来源:origin: org.apache.rya/rya.pcj.fluo.api

private String[] getAuths(final Connector accumulo) {
Authorizations auths;
try {
auths = accumulo.securityOperations().getUserAuthorizations(accumulo.whoami());
final List authList = auths.getAuthorizations();
final String[] authArray = new String[authList.size()];
for(int i = 0; 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());
}
}
}

代码示例来源:origin: apache/incubator-rya

private String[] getAuths(final Connector accumulo) {
Authorizations auths;
try {
auths = accumulo.securityOperations().getUserAuthorizations(accumulo.whoami());
final List authList = auths.getAuthorizations();
final String[] authArray = new String[authList.size()];
for(int i = 0; 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());
}
}
}

代码示例来源:origin: NationalSecurityAgency/datawave

private void retrieveAccumuloAuthorizations() throws Exception {
Map trackingMap = accumuloConnectionFactory.getTrackingMap(Thread.currentThread().getStackTrace());
Connector c = accumuloConnectionFactory.getConnection(AccumuloConnectionFactory.Priority.ADMIN, trackingMap);
try {
Authorizations auths = c.securityOperations().getUserAuthorizations(c.whoami());
HashSet authSet = new HashSet<>();
for (byte[] auth : auths.getAuthorizations()) {
authSet.add(new String(auth).intern());
}
accumuloUserAuths = Collections.unmodifiableSet(authSet);
log.debug("Accumulo User Authorizations: {}", accumuloUserAuths);
} finally {
accumuloConnectionFactory.returnConnection(c);
}
}
}

代码示例来源:origin: org.securegraph.examples/examples-base

protected void addAuthorizationToUser(String visibilityString) {
LOGGER.debug("adding auth " + visibilityString);
if (getGraph() instanceof AccumuloGraph) {
try {
org.apache.accumulo.core.client.Connector cOnnector= ((AccumuloGraph) getGraph()).getConnector();
String principal = ((AccumuloGraph) getGraph()).getConnector().whoami();
org.apache.accumulo.core.security.Authorizations authorizatiOns= connector.securityOperations().getUserAuthorizations(principal);
if (authorizations.contains(visibilityString)) {
return;
}
String[] newAuthorizatiOns= new String[authorizations.getAuthorizations().size() + 1];
int i;
for (i = 0; i newAuthorizations[i] = new String(authorizations.getAuthorizations().get(i));
}
newAuthorizations[i] = visibilityString;
connector.securityOperations().changeUserAuthorizations(principal, new org.apache.accumulo.core.security.Authorizations(newAuthorizations));
} catch (Exception ex) {
throw new RuntimeException("Could not add auths", ex);
}
} else {
throw new RuntimeException("Unhandled graph type to add authorizations: " + getGraph().getClass().getName());
}
}

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

@Override
public void execute(ClientService.Client client) throws Exception {
client.changeAuthorizations(Tracer.traceInfo(), context.rpcCreds(), principal,
ByteBufferUtil.toByteBuffers(authorizations.getAuthorizations()));
}
});

推荐阅读
author-avatar
求学lx
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有